Class: LevelDb::Snapshot

Inherits:
Object
  • Object
show all
Includes:
Encoding
Defined in:
lib/level_db.rb

Instance Method Summary collapse

Methods included from Encoding

#decode_key, #decode_value, #encode_key, #encode_value

Constructor Details

#initialize(db) ⇒ Snapshot

Returns a new instance of Snapshot.



291
292
293
294
295
296
# File 'lib/level_db.rb', line 291

def initialize(db)
  @db = db
  @snapshot = @db.snapshot
  @read_options = Library::ReadOptions.new
  @read_options.snapshot(@snapshot)
end

Instance Method Details

#closeObject



303
304
305
# File 'lib/level_db.rb', line 303

def close
  @snapshot.close
end

#get(key) ⇒ Object



298
299
300
301
# File 'lib/level_db.rb', line 298

def get(key)
  value = @db.get(encode_key(key), @read_options)
  value && decode_value(value)
end