Class: SplitIoClient::LocalStore
- Inherits:
-
Object
- Object
- SplitIoClient::LocalStore
- Defined in:
- lib/splitclient-cache/local_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
deletes value from cache by given key.
-
#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
13 14 15 |
# File 'lib/splitclient-cache/local_store.rb', line 13 def initialize @cache = ThreadSafe::Cache.new end |
Instance Method Details
#delete(key) ⇒ Object
deletes value from cache by given key
39 40 41 |
# File 'lib/splitclient-cache/local_store.rb', line 39 def delete(key) @cache[key] = nil end |
#read(key) ⇒ Object
Read a value from the cache
22 23 24 |
# File 'lib/splitclient-cache/local_store.rb', line 22 def read(key) @cache[key] end |
#write(key, value) ⇒ Object
Store a value in the cache
32 33 34 |
# File 'lib/splitclient-cache/local_store.rb', line 32 def write(key, value) @cache[key] = value end |