Class: Moneta::Adapters::TokyoCabinet
- Defined in:
- lib/moneta/adapters/tokyocabinet.rb
Overview
TokyoCabinet backend
Instance Method Summary collapse
-
#close ⇒ Object
Explicitly close the store.
-
#delete(key, options = {}) ⇒ Object
Delete the key from the store and return the current value.
-
#initialize(options = {}) ⇒ TokyoCabinet
constructor
A new instance of TokyoCabinet.
Methods included from IncrementSupport
Methods included from HashAdapter
Methods included from Defaults
#[], #[]=, #decrement, #fetch, #increment, #key?
Methods included from OptionSupport
#expires, #prefix, #raw, #with
Constructor Details
#initialize(options = {}) ⇒ TokyoCabinet
Returns a new instance of TokyoCabinet.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/moneta/adapters/tokyocabinet.rb', line 11 def initialize( = {}) file = [:file] raise ArgumentError, 'Option :file is required' unless [:file] if [:type] == :bdb @hash = ::TokyoCabinet::BDB.new @hash.open(file, ::TokyoCabinet::BDB::OWRITER | ::TokyoCabinet::BDB::OCREAT) else @hash = ::TokyoCabinet::HDB.new @hash.open(file, ::TokyoCabinet::HDB::OWRITER | ::TokyoCabinet::HDB::OCREAT) end or raise @hash.errmsg(@hash.ecode) end |
Instance Method Details
#close ⇒ Object
Explicitly close the store
33 34 35 36 |
# File 'lib/moneta/adapters/tokyocabinet.rb', line 33 def close @hash.close nil end |
#delete(key, options = {}) ⇒ Object
Delete the key from the store and return the current value
24 25 26 27 28 29 30 |
# File 'lib/moneta/adapters/tokyocabinet.rb', line 24 def delete(key, = {}) value = load(key, ) if value @hash.delete(key) value end end |