Class: Isomorfeus::Preact::RedisComponentCache
- Defined in:
- lib/isomorfeus/preact/redis_component_cache.rb
Instance Method Summary collapse
- #fetch(key) ⇒ Object
-
#initialize(*args) ⇒ RedisComponentCache
constructor
A new instance of RedisComponentCache.
- #store(key, rendered_tree, response_status, styles) ⇒ Object
Constructor Details
#initialize(*args) ⇒ RedisComponentCache
Returns a new instance of RedisComponentCache.
4 5 6 |
# File 'lib/isomorfeus/preact/redis_component_cache.rb', line 4 def initialize(*args) @redis_client = Redis.new(@args) end |
Instance Method Details
#fetch(key) ⇒ Object
8 9 10 11 |
# File 'lib/isomorfeus/preact/redis_component_cache.rb', line 8 def fetch(key) json = @redis_client.get(key) Oj.load(json, mode: :strict) end |
#store(key, rendered_tree, response_status, styles) ⇒ Object
13 14 15 16 |
# File 'lib/isomorfeus/preact/redis_component_cache.rb', line 13 def store(key, rendered_tree, response_status, styles) json = Oj.dump([rendered_tree, response_status, styles], mode: :strict) @redis_client.set(key, json) end |