Class: LevelDBNative::Snapshot

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/leveldb-native.rb

Overview

Snapshot has the same API as DB, restricted to read access.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(db) ⇒ Object



115
116
117
# File 'lib/leveldb-native.rb', line 115

def self.new(db)
  make db
end

Instance Method Details

#each(*args, &block) ⇒ Object



119
120
121
122
123
# File 'lib/leveldb-native.rb', line 119

def each(*args, &block)
  i = iterator(*args)
  i.each(&block) if block
  i
end

#get(*args) ⇒ Object Also known as: []



125
126
127
# File 'lib/leveldb-native.rb', line 125

def get(*args)
  db.get(*args, snapshot: self)
end

#inspectObject



138
139
140
# File 'lib/leveldb-native.rb', line 138

def inspect
  "<#{self.class} #{db.inspect} #{' (released)' if released?}>"
end

#iterator(*args) ⇒ Object



134
# File 'lib/leveldb-native.rb', line 134

def iterator(*args); db.iterator *args, snapshot: self; end

#keysObject



135
# File 'lib/leveldb-native.rb', line 135

def keys; map {|k, v| k} end

#valuesObject



136
# File 'lib/leveldb-native.rb', line 136

def values; map {|k, v| v} end