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.
237 238 239 240 241 242 |
# File 'lib/drip.rb', line 237 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
225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/drip.rb', line 225 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
221 222 223 |
# File 'lib/drip.rb', line 221 def self.reader(name) self.to_enum(:each, name) end |