Module: RailsIdentity::Cache
- Defined in:
- lib/rails_identity/cache.rb
Overview
Use this module to read from and write to cache so prefix is consistently enforced.
Constant Summary collapse
- CACHE_VERSION =
"0.0.1"
Class Method Summary collapse
Class Method Details
.cache_key(key) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/rails_identity/cache.rb', line 11 def self.cache_key(key) if key.is_a? Hash key["_version"] = VERSION return key else return {key: key, _version: VERSION} end end |
.get(key) ⇒ Object
20 21 22 |
# File 'lib/rails_identity/cache.rb', line 20 def self.get(key) return Rails.cache.fetch(cache_key(key)) end |
.set(key, value) ⇒ Object
24 25 26 |
# File 'lib/rails_identity/cache.rb', line 24 def self.set(key, value) Rails.cache.write(cache_key(key), value) end |