Class: Roda::RodaPlugins::PerThreadCaching::Cache
- Inherits:
-
Object
- Object
- Roda::RodaPlugins::PerThreadCaching::Cache
- Defined in:
- lib/roda/plugins/per_thread_caching.rb
Constant Summary collapse
- MUTEX =
Mutex used to ensure multiple per-thread caches don’t use the same key
::Mutex.new
- N =
Auto incrementing number proc used to make sure multiple thread-thread caches don’t use the same key.
lambda{MUTEX.synchronize{n += 1}}
Instance Method Summary collapse
-
#[](key) ⇒ Object
Return the current thread’s cached value.
-
#[]=(key, value) ⇒ Object
Set the current thread’s cached value.
-
#initialize ⇒ Cache
constructor
Store unique symbol used to look up in the per thread caches.
Constructor Details
Instance Method Details
#[](key) ⇒ Object
Return the current thread’s cached value.
43 44 45 |
# File 'lib/roda/plugins/per_thread_caching.rb', line 43 def [](key) _hash[key] end |
#[]=(key, value) ⇒ Object
Set the current thread’s cached value.
48 49 50 |
# File 'lib/roda/plugins/per_thread_caching.rb', line 48 def []=(key, value) _hash[key] = value end |