Class: LaunchDarkly::ThreadSafeMemoryStore
- Inherits:
-
Object
- Object
- LaunchDarkly::ThreadSafeMemoryStore
- Defined in:
- lib/ldclient-rb/cache_store.rb
Overview
A thread-safe in-memory store suitable for use with the Faraday caching HTTP client. Uses the Threadsafe gem as the underlying cache.
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
16 17 18 |
# File 'lib/ldclient-rb/cache_store.rb', line 16 def initialize @cache = ThreadSafe::Cache.new end |
Instance Method Details
#delete(key) ⇒ Object
Delete a value in the cache
42 43 44 |
# File 'lib/ldclient-rb/cache_store.rb', line 42 def delete(key) @cache.delete(key) end |
#read(key) ⇒ Object
Read a value from the cache
25 26 27 |
# File 'lib/ldclient-rb/cache_store.rb', line 25 def read(key) @cache[key] end |
#write(key, value) ⇒ Object
Store a value in the cache
35 36 37 |
# File 'lib/ldclient-rb/cache_store.rb', line 35 def write(key, value) @cache[key] = value end |