Class: LaunchDarkly::ThreadSafeMemoryStore
- Inherits:
-
Object
- Object
- LaunchDarkly::ThreadSafeMemoryStore
- Defined in:
- lib/ldclient-rb/cache_store.rb
Overview
A thread-safe in-memory store that uses the same semantics that Faraday would expect, although we no longer use Faraday. This is used by Requestor, when we are not in a Rails environment.
Instance Method Summary collapse
-
#delete(key) ⇒ Object
Delete a value in the cache.
-
#initialize ⇒ ThreadSafeMemoryStore
constructor
Default constructor.
-
#read(key) ⇒ Object
Read a value from the cache.
-
#write(key, value) ⇒ Object
Store a value in the cache.
Constructor Details
#initialize ⇒ ThreadSafeMemoryStore
Default constructor
15 16 17 |
# File 'lib/ldclient-rb/cache_store.rb', line 15 def initialize @cache = Concurrent::Map.new end |
Instance Method Details
#delete(key) ⇒ Object
Delete a value in the cache
41 42 43 |
# File 'lib/ldclient-rb/cache_store.rb', line 41 def delete(key) @cache.delete(key) end |
#read(key) ⇒ Object
Read a value from the cache
24 25 26 |
# File 'lib/ldclient-rb/cache_store.rb', line 24 def read(key) @cache[key] end |
#write(key, value) ⇒ Object
Store a value in the cache
34 35 36 |
# File 'lib/ldclient-rb/cache_store.rb', line 34 def write(key, value) @cache[key] = value end |