diff --git a/src/cached.cr b/src/cached.cr index 2d961f5..33a53ba 100644 --- a/src/cached.cr +++ b/src/cached.cr @@ -1,3 +1,7 @@ +require "file_utils" +require "json" + +require "./dodb.cr" #class Hash(K,V) # def reverse @@ -37,6 +41,7 @@ class DODB::DataBase::Cached(V) self[index] = item self.last_index = index @data[self.last_index] = item + self.last_index end # Getting data from the hash in RAM. @@ -49,7 +54,7 @@ class DODB::DataBase::Cached(V) def [](key : Int32) : V # raise MissingEntry.new(key) unless ::File.exists? file_path key # read file_path key - @data[key] + @data[key] rescue raise MissingEntry.new(key) end def []=(index : Int32, value : V) @@ -301,4 +306,3 @@ class DODB::DataBase::Cached(V) end end end -