Class: Webhookdb::Idempotency::InMemory
- Inherits:
-
Object
- Object
- Webhookdb::Idempotency::InMemory
- Defined in:
- lib/webhookdb/idempotency.rb
Instance Method Summary collapse
- #ensure(_key) ⇒ Object
- #finish(key, last_run:, stored:, result:) ⇒ Object
-
#initialize(cache, store) ⇒ InMemory
constructor
A new instance of InMemory.
- #lock(key) ⇒ Object
- #transaction ⇒ Object
Constructor Details
#initialize(cache, store) ⇒ InMemory
Returns a new instance of InMemory.
153 154 155 156 |
# File 'lib/webhookdb/idempotency.rb', line 153 def initialize(cache, store) @cache = cache @store = store end |
Instance Method Details
#ensure(_key) ⇒ Object
158 |
# File 'lib/webhookdb/idempotency.rb', line 158 def ensure(_key) = nil |
#finish(key, last_run:, stored:, result:) ⇒ Object
162 163 164 165 |
# File 'lib/webhookdb/idempotency.rb', line 162 def finish(key, last_run:, stored:, result:) @cache[key] = last_run @store[key] = result if stored end |
#lock(key) ⇒ Object
159 |
# File 'lib/webhookdb/idempotency.rb', line 159 def lock(key) = {last_run: @cache[key], stored_result: @store[key]} |
#transaction ⇒ Object
160 |
# File 'lib/webhookdb/idempotency.rb', line 160 def transaction(&) = yield |