Module: Plezi::Base::HasStore
- Included in:
- RenderERB, RenderMarkDown, RenderSlim
- Defined in:
- lib/plezi/render/has_cache.rb
Overview
Provides thread-specific caching engine, allowing lockless cache at the expenss of memory.
Instance Method Summary collapse
-
#get(key) ⇒ Object
(also: #[])
Retrieves data form the cache.
-
#store(key, value) ⇒ Object
(also: #[]=)
Stores data in the cache.
Instance Method Details
#get(key) ⇒ Object Also known as: []
Retrieves data form the cache
30 31 32 |
# File 'lib/plezi/render/has_cache.rb', line 30 def get(key) (Thread.current[(@_chache_name ||= object_id.to_s(16))] ||= {}.dup)[key] end |
#store(key, value) ⇒ Object Also known as: []=
Stores data in the cache
25 26 27 |
# File 'lib/plezi/render/has_cache.rb', line 25 def store(key, value) (Thread.current[(@_chache_name ||= object_id.to_s(16))] ||= {}.dup)[key] = value end |