Sha256: 2fdc2917771f1355c648d39db9f1dab048a49bcd22ad0f5e9e25458ada0113bd
Contents?: true
Size: 779 Bytes
Versions: 4
Compression:
Stored size: 779 Bytes
Contents
# frozen_string_literal: true module Streamdal class KeyValue def initialize @kvs = {} @mtx = Mutex.new end def set(key, value) @mtx.synchronize do @kvs[key] = value end end def get(key) @mtx.synchronize do @kvs[key] end end def delete(key) @mtx.synchronize do @kvs.delete(key) end end def keys @mtx.synchronize do @kvs.keys end end def items @mtx.synchronize do @kvs.values end end def exists(key) @mtx.synchronize do @kvs.key?(key) end end def purge @mtx.synchronize do num_keys = @kvs.keys.length @kvs = {} num_keys end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
streamdal-0.0.5 | lib/kv.rb |
streamdal-0.0.4 | lib/kv.rb |
streamdal-0.0.3 | lib/kv.rb |
streamdal-0.0.2 | lib/kv.rb |