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.
46 47 48 |
# File 'lib/roda/plugins/per_thread_caching.rb', line 46 def [](key) _hash[key] end |
#[]=(key, value) ⇒ Object
Set the current thread’s cached value.
51 52 53 |
# File 'lib/roda/plugins/per_thread_caching.rb', line 51 def []=(key, value) _hash[key] = value end |