Class: Moneta::Adapters::LevelDB
- Defined in:
- lib/moneta/adapters/leveldb.rb
Overview
LevelDB backend
Instance Method Summary collapse
-
#clear(options = {}) ⇒ void
Clear all keys in this store.
-
#close ⇒ Object
Explicitly close the store.
-
#initialize(options = {}) ⇒ LevelDB
constructor
A new instance of LevelDB.
-
#key?(key, options = {}) ⇒ Boolean
Exists the value with key.
Methods included from IncrementSupport
Methods included from HashAdapter
Methods included from Defaults
#[], #[]=, #decrement, #fetch, #increment
Methods included from OptionSupport
#expires, #prefix, #raw, #with
Constructor Details
#initialize(options = {}) ⇒ LevelDB
Returns a new instance of LevelDB.
11 12 13 14 |
# File 'lib/moneta/adapters/leveldb.rb', line 11 def initialize( = {}) raise ArgumentError, 'Option :dir is required' unless [:dir] @hash = ::LevelDB::DB.new([:dir]) end |
Instance Method Details
#clear(options = {}) ⇒ void
This method returns an undefined value.
Clear all keys in this store
22 23 24 25 |
# File 'lib/moneta/adapters/leveldb.rb', line 22 def clear( = {}) @hash.each {|k,v| delete(k, ) } self end |
#close ⇒ Object
Explicitly close the store
28 29 30 31 |
# File 'lib/moneta/adapters/leveldb.rb', line 28 def close @hash.close nil end |
#key?(key, options = {}) ⇒ Boolean
Exists the value with key
17 18 19 |
# File 'lib/moneta/adapters/leveldb.rb', line 17 def key?(key, = {}) @hash.includes?(key) end |