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.



255
256
257
258
259
260
# File 'lib/level_db.rb', line 255

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

Instance Method Details

#closeObject



267
268
269
# File 'lib/level_db.rb', line 267

def close
  @snapshot.close
end

#get(key) ⇒ Object



262
263
264
265
# File 'lib/level_db.rb', line 262

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