Class: Isomorfeus::Professional::RedisComponentCache

Inherits:
Object
  • Object
show all
Defined in:
lib/isomorfeus/react/redis_component_cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RedisComponentCache

Returns a new instance of RedisComponentCache.



4
5
6
# File 'lib/isomorfeus/react/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/react/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/react/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