Class: Moneta::Adapters::LevelDB
- Defined in:
- lib/moneta/adapters/leveldb.rb
Overview
LevelDB backend
Instance Attribute Summary
Attributes included from HashAdapter
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 CreateSupport
Methods included from IncrementSupport
Methods included from HashAdapter
Methods included from Defaults
#[], #[]=, #create, #decrement, #features, #fetch, included, #increment, #supports?
Methods included from OptionSupport
#expires, #prefix, #raw, #with
Constructor Details
#initialize(options = {}) ⇒ LevelDB
Returns a new instance of LevelDB.
12 13 14 15 16 17 18 |
# File 'lib/moneta/adapters/leveldb.rb', line 12 def initialize( = {}) @backend = [:backend] || begin raise ArgumentError, 'Option :dir is required' unless [:dir] ::LevelDB::DB.new([:dir]) end end |
Instance Method Details
#clear(options = {}) ⇒ void
This method returns an undefined value.
Clear all keys in this store
26 27 28 29 |
# File 'lib/moneta/adapters/leveldb.rb', line 26 def clear( = {}) @backend.each {|k,v| delete(k, ) } self end |
#close ⇒ Object
Explicitly close the store
32 33 34 35 |
# File 'lib/moneta/adapters/leveldb.rb', line 32 def close @backend.close nil end |
#key?(key, options = {}) ⇒ Boolean
Exists the value with key
21 22 23 |
# File 'lib/moneta/adapters/leveldb.rb', line 21 def key?(key, = {}) @backend.includes?(key) end |