Class: GoFlippy::MemoryStore
- Inherits:
-
Object
- Object
- GoFlippy::MemoryStore
- Defined in:
- lib/goflippy-ruby/memory_store.rb
Instance Method Summary collapse
- #find(key) ⇒ Object
-
#initialize ⇒ MemoryStore
constructor
A new instance of MemoryStore.
- #put(key, val) ⇒ Object
- #refresh!(keys) ⇒ Object
Constructor Details
#initialize ⇒ MemoryStore
Returns a new instance of MemoryStore.
5 6 7 |
# File 'lib/goflippy-ruby/memory_store.rb', line 5 def initialize @store = Concurrent::Hash.new({}) end |
Instance Method Details
#find(key) ⇒ Object
9 10 11 |
# File 'lib/goflippy-ruby/memory_store.rb', line 9 def find(key) @store[key] end |
#put(key, val) ⇒ Object
13 14 15 |
# File 'lib/goflippy-ruby/memory_store.rb', line 13 def put(key, val) @store[key.to_sym] = val end |
#refresh!(keys) ⇒ Object
17 18 19 |
# File 'lib/goflippy-ruby/memory_store.rb', line 17 def refresh!(keys) @store = Concurrent::Hash.new(@store.select { |k, _| keys.include?(k) }) end |