Class: Isomorfeus::Preact::MemcachedComponentCache

Inherits:
Object
  • Object
show all
Defined in:
lib/isomorfeus/preact/memcached_component_cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ MemcachedComponentCache

Returns a new instance of MemcachedComponentCache.



4
5
6
# File 'lib/isomorfeus/preact/memcached_component_cache.rb', line 4

def initialize(*args)
  @dalli_client = Dalli::Client.new(*args)
end

Instance Method Details

#fetch(key) ⇒ Object



8
9
10
11
# File 'lib/isomorfeus/preact/memcached_component_cache.rb', line 8

def fetch(key)
  json = @dalli_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/memcached_component_cache.rb', line 13

def store(key, rendered_tree, response_status, styles)
  json = Oj.dump([rendered_tree, response_status, styles], mode: :strict)
  @dalli_client.set(key, json)
end