Class: RocksDB::DB
Constant Summary collapse
- @@cache =
{}
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object (also: #close!)
- #each(&block) ⇒ Object
-
#initialize(*args) ⇒ DB
constructor
A new instance of DB.
Constructor Details
#initialize(*args) ⇒ DB
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rocksdb.rb', line 26 def initialize *args readonly = !!(args[1] && args[1][:readonly]) @key = args[0] if !readonly and @@cache[@key] __initialize2(*args) raise DBError.new("error #{@key.to_s} alread open") end __initialize(*args) unless readonly @@cache[@key] = self end end |
Class Method Details
.get_instance(*args) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rocksdb.rb', line 12 def get_instance *args readonly = !!(args[1] && args[1][:readonly]) key = args[0] if readonly return new(*args) end unless @@cache[key] @@cache[key] = new(*args) end @@cache[key] end |
Instance Method Details
#close ⇒ Object Also known as: close!
39 40 41 42 |
# File 'lib/rocksdb.rb', line 39 def close @@cache.delete(@key) __close end |
#each(&block) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/rocksdb.rb', line 51 def each(&block) if block_given? self.each_with_index do |key, value| block.call(value) end else self.iterator end end |