Class: Isomorfeus::Preact::ThreadLocalComponentCache

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

Instance Method Summary collapse

Constructor Details

#initializeThreadLocalComponentCache

Returns a new instance of ThreadLocalComponentCache.



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

def initialize
  Thread.current[:local_cache] = {} unless Thread.current.key?(:local_cache)
end

Instance Method Details

#fetch(key) ⇒ Object



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

def fetch(key)
  Thread.current[:local_cache][key]
end

#store(key, rendered_tree, response_status, styles) ⇒ Object



12
13
14
# File 'lib/isomorfeus/preact/thread_local_component_cache.rb', line 12

def store(key, rendered_tree, response_status, styles)
  Thread.current[:local_cache][key] = [rendered_tree, response_status, styles]
end