Class: Interceptors::IdempotencyInterceptor::MemoryStore
- Inherits:
-
Object
- Object
- Interceptors::IdempotencyInterceptor::MemoryStore
- Defined in:
- lib/interceptors/idempotency_interceptor.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #delete(key) ⇒ Object
-
#initialize ⇒ MemoryStore
constructor
A new instance of MemoryStore.
- #read(key) ⇒ Object
- #write(key, value, ttl: nil) ⇒ Object
Constructor Details
#initialize ⇒ MemoryStore
Returns a new instance of MemoryStore.
8 9 10 11 |
# File 'lib/interceptors/idempotency_interceptor.rb', line 8 def initialize @data = {} @mutex = Mutex.new end |
Instance Method Details
#clear ⇒ Object
26 27 28 |
# File 'lib/interceptors/idempotency_interceptor.rb', line 26 def clear @mutex.synchronize { @data.clear } end |
#delete(key) ⇒ Object
22 23 24 |
# File 'lib/interceptors/idempotency_interceptor.rb', line 22 def delete(key) @mutex.synchronize { @data.delete(key) } end |
#read(key) ⇒ Object
13 14 15 |
# File 'lib/interceptors/idempotency_interceptor.rb', line 13 def read(key) @mutex.synchronize { @data[key] } end |
#write(key, value, ttl: nil) ⇒ Object
17 18 19 20 |
# File 'lib/interceptors/idempotency_interceptor.rb', line 17 def write(key, value, ttl: nil) @mutex.synchronize { @data[key] = value } value end |