Sha256: 44208f300362a47f4457aaf36033c27dc51f1d4e6b3f293abbe409661e024a3f
Contents?: true
Size: 773 Bytes
Versions: 3
Compression:
Stored size: 773 Bytes
Contents
class Idempo::MemoryBackend def initialize require_relative "response_store" @lock = Idempo::MemoryLock.new @response_store = Idempo::ResponseStore.new @store_mutex = Mutex.new end class Store < Struct.new(:store_mutex, :response_store, :key, keyword_init: true) def lookup store_mutex.synchronize do response_store.lookup(key) end end def store(data:, ttl:) store_mutex.synchronize do response_store.save(key, data, ttl) end end end def with_idempotency_key(request_key) @lock.with(request_key) do store = Store.new(store_mutex: @store_mutex, response_store: @response_store, key: request_key) yield(store) end end def prune! @response_store.prune end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
idempo-1.3.0 | lib/idempo/memory_backend.rb |
idempo-1.2.2 | lib/idempo/memory_backend.rb |
idempo-1.2.1 | lib/idempo/memory_backend.rb |