Class: Isomorfeus::ThreadLocalComponentCache

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

Instance Method Summary collapse

Constructor Details

#initializeThreadLocalComponentCache

Returns a new instance of ThreadLocalComponentCache.



3
4
5
# File 'lib/isomorfeus/react/thread_local_component_cache.rb', line 3

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

Instance Method Details

#fetch(key) ⇒ Object



7
8
9
# File 'lib/isomorfeus/react/thread_local_component_cache.rb', line 7

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

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



11
12
13
# File 'lib/isomorfeus/react/thread_local_component_cache.rb', line 11

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