class Roda::RodaPlugins::PerThreadCaching::Cache
Constants
- MUTEX
Mutex used to ensure multiple per-thread caches don’t use the same key
- N
Auto incrementing number proc used to make sure multiple thread-thread caches don’t use the same key.
Public Class Methods
new()
click to toggle source
Store unique symbol used to look up in the per thread caches.
# File lib/roda/plugins/per_thread_caching.rb, line 38 def initialize @o = :"roda_per_thread_cache_#{N.call}" end
Public Instance Methods
[](key)
click to toggle source
Return the current thread’s cached value.
# File lib/roda/plugins/per_thread_caching.rb, line 43 def [](key) _hash[key] end
[]=(key, value)
click to toggle source
Set the current thread’s cached value.
# File lib/roda/plugins/per_thread_caching.rb, line 48 def []=(key, value) _hash[key] = value end
Private Instance Methods
_hash()
click to toggle source
The current thread’s cache.
# File lib/roda/plugins/per_thread_caching.rb, line 55 def _hash ::Thread.current[@o] ||= {} end