Class: LevelDb::Db
- Inherits:
-
Object
show all
- Includes:
- Crud
- Defined in:
- lib/level_db.rb
Instance Method Summary
collapse
Methods included from Crud
#delete, #get, #put
Methods included from Encoding
#decode_key, #decode_value, #encode_key, #encode_value
Constructor Details
#initialize(db) ⇒ Db
Returns a new instance of Db.
89
90
91
|
# File 'lib/level_db.rb', line 89
def initialize(db)
@db = db
end
|
Instance Method Details
#batch(&block) ⇒ Object
97
98
99
100
101
102
103
104
105
|
# File 'lib/level_db.rb', line 97
def batch(&block)
batch = @db.create_write_batch
begin
yield Batch.new(batch)
@db.write(batch)
ensure
batch.close
end
end
|
#close ⇒ Object
93
94
95
|
# File 'lib/level_db.rb', line 93
def close
@db.close
end
|
#each(options = {}, &block) ⇒ Object
107
108
109
110
111
|
# File 'lib/level_db.rb', line 107
def each(options={}, &block)
cursor = Cursor.new(@db.iterator, options)
cursor.each(&block) if block_given?
cursor
end
|
#snapshot ⇒ Object
113
114
115
|
# File 'lib/level_db.rb', line 113
def snapshot
Snapshot.new(@db)
end
|