Class: Webhookdb::Idempotency::InMemory

Inherits:
Object
  • Object
show all
Defined in:
lib/webhookdb/idempotency.rb

Instance Method Summary collapse

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]}

#transactionObject



160
# File 'lib/webhookdb/idempotency.rb', line 160

def transaction(&) = yield