Class: ODB::FileStore

Inherits:
DataStore show all
Defined in:
lib/odb.rb

Instance Attribute Summary

Attributes inherited from DataStore

#db, #key_cache, #name

Instance Method Summary collapse

Methods inherited from DataStore

#[], #[]=, #read, #write

Constructor Details

#initialize(name) ⇒ FileStore

Returns a new instance of FileStore.



113
114
115
116
117
118
119
# File 'lib/odb.rb', line 113

def initialize(name)
  super(name)
  FileUtils.mkdir_p(name)
  if File.file?(resource("__key_cache"))
    @key_cache = Marshal.load(IO.read(resource("__key_cache")))
  end
end

Instance Method Details

#after_commitObject



121
122
123
124
125
# File 'lib/odb.rb', line 121

def after_commit
  File.open(resource("__key_cache"), "wb") do |file|
    file.write(Marshal.dump(key_cache))
  end
end