Sha256: e4250129837f360e3b4584d43aaa5e7e6b0b8e4fe369a7a7209b8d07965b1ec2
Contents?: true
Size: 709 Bytes
Versions: 6
Compression:
Stored size: 709 Bytes
Contents
module Asynchronic module DataStore class InMemory include Helper def initialize(hash={}) @hash = {} @mutex = Mutex.new self.class.connections[object_id] = self end def [](key) @hash[key.to_s] end def []=(key, value) @mutex.synchronize { @hash[key.to_s] = value } end def delete(key) @hash.delete key.to_s end def keys @hash.keys.map { |k| Key.new k } end alias_method :connection, :object_id def self.connect(object_id) connections[object_id] end private def self.connections @connections ||= {} end end end end
Version data entries
6 entries across 6 versions & 1 rubygems