Class: Luoma::ThreadSafeLRUCache
- Includes:
- MonitorMixin
- Defined in:
- lib/luoma/cache.rb,
sig/luoma/cache.rbs
Overview
A thread safe least recently used cache.
Instance Attribute Summary
Attributes inherited from LRUCache
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(max_size = 128) ⇒ ThreadSafeLRUCache
constructor
A new instance of ThreadSafeLRUCache.
- #keys ⇒ Array[Integer]
- #length ⇒ Integer
- #unsafe_get ⇒ Object
- #unsafe_keys ⇒ Object
- #unsafe_length ⇒ Object
- #unsafe_set ⇒ Object
Constructor Details
#initialize(max_size = 128) ⇒ ThreadSafeLRUCache
Returns a new instance of ThreadSafeLRUCache.
52 53 54 |
# File 'lib/luoma/cache.rb', line 52 def initialize(max_size = 128) super end |
Instance Method Details
#[](key) ⇒ Object
56 57 58 59 60 |
# File 'lib/luoma/cache.rb', line 56 def [](key) synchronize do unsafe_get(key) end end |
#[]=(key, value) ⇒ Object
62 63 64 65 66 |
# File 'lib/luoma/cache.rb', line 62 def []=(key, value) synchronize do unsafe_set(key, value) end end |
#keys ⇒ Array[Integer]
74 75 76 77 78 |
# File 'lib/luoma/cache.rb', line 74 def keys synchronize do unsafe_keys end end |
#length ⇒ Integer
68 69 70 71 72 |
# File 'lib/luoma/cache.rb', line 68 def length synchronize do unsafe_length end end |
#unsafe_get ⇒ Object
47 |
# File 'lib/luoma/cache.rb', line 47 alias unsafe_get [] |
#unsafe_keys ⇒ Object
50 |
# File 'lib/luoma/cache.rb', line 50 alias unsafe_keys keys |
#unsafe_length ⇒ Object
49 |
# File 'lib/luoma/cache.rb', line 49 alias unsafe_length length |
#unsafe_set ⇒ Object
48 |
# File 'lib/luoma/cache.rb', line 48 alias unsafe_set []= |