Class: GoFlippy::MemoryStore

Inherits:
Object
  • Object
show all
Defined in:
lib/goflippy-ruby/memory_store.rb

Instance Method Summary collapse

Constructor Details

#initializeMemoryStore

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