Class: Drip::SimpleStore
- Inherits:
-
Object
- Object
- Drip::SimpleStore
- Defined in:
- lib/drip.rb
Defined Under Namespace
Classes: Attic, AtticCache
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, option = {}) ⇒ SimpleStore
constructor
A new instance of SimpleStore.
- #write(key, value) ⇒ Object
Constructor Details
#initialize(name, option = {}) ⇒ SimpleStore
Returns a new instance of SimpleStore.
259 260 261 262 263 264 |
# File 'lib/drip.rb', line 259 def initialize(name, option={}) @name = name @file = nil cache_size = option.fetch(:cache_size, 8) @cache = AtticCache.new(cache_size) if @name end |
Class Method Details
.each(name) ⇒ Object
247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/drip.rb', line 247 def self.each(name) file = File.open(name, 'rb') while true pos = file.pos key, value = Marshal.load(file) yield(key, value, Attic.new(name, pos, value)) end rescue EOFError ensure file.close if file end |
.reader(name) ⇒ Object
243 244 245 |
# File 'lib/drip.rb', line 243 def self.reader(name) self.to_enum(:each, name) end |