Sha256: 0fbe846771479beacdc877b564c26d58e7b50cb988013a6acb4e38cbb927a7c4
Contents?: true
Size: 546 Bytes
Versions: 1
Compression:
Stored size: 546 Bytes
Contents
require 'speed_gun/store' class SpeedGun::Store::MemoryStore < SpeedGun::Store DEFAULT_MAX_ENTRIES = 1000 def initialize(options = {}) @max_entries = options[:max_entries] || DEFAULT_MAX_ENTRIES @store = {} @stored_list = [] end def save(object) id = "#{object.class.name}-#{object.id}" @store[id] = object.to_hash @stored_list.push(id) @store.delete(@stored_list.shift) while @stored_list.length > @max_entries end def load(klass, id) klass.from_hash(id, @store["#{klass.name}-#{id}"]) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
speed_gun-1.0.0.rc1 | lib/speed_gun/store/memory_store.rb |