Class: Cache::Backend::IronCache
- Inherits:
-
Object
- Object
- Cache::Backend::IronCache
- Defined in:
- lib/cache-backend-iron-cache.rb,
lib/cache-backend-iron-cache/version.rb
Constant Summary collapse
- VERSION =
"0.0.4"
Instance Method Summary collapse
- #get(key) ⇒ Object
-
#initialize(project_id, token, cache, options = {}) ⇒ IronCache
constructor
A new instance of IronCache.
- #set(key, value) ⇒ Object
Constructor Details
#initialize(project_id, token, cache, options = {}) ⇒ IronCache
Returns a new instance of IronCache.
9 10 11 12 |
# File 'lib/cache-backend-iron-cache.rb', line 9 def initialize(project_id, token, cache, = {}) = {project_id: project_id, token: token}.merge() @client = ::IronCache::Client.new().cache(cache) end |
Instance Method Details
#get(key) ⇒ Object
14 15 16 17 18 |
# File 'lib/cache-backend-iron-cache.rb', line 14 def get(key) value = @client.get(key) return unless value JSON.parse(value.value)['value'] end |
#set(key, value) ⇒ Object
20 21 22 23 |
# File 'lib/cache-backend-iron-cache.rb', line 20 def set(key, value) @client.put(key, JSON.dump({value: value})) value end |