Class: Moneta::Adapters::TokyoCabinet
- Defined in:
- lib/moneta/adapters/tokyocabinet.rb
Overview
TokyoCabinet backend
Instance Method Summary collapse
- #close ⇒ Object
- #delete(key, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ TokyoCabinet
constructor
Constructor.
Methods included from Mixins::HashAdapter
Methods included from Mixins::IncrementSupport
Methods inherited from Base
#[], #[]=, #decrement, #fetch, #increment, #key?
Methods included from Mixins::WithOptions
#expires, #prefix, #raw, #with
Constructor Details
#initialize(options = {}) ⇒ TokyoCabinet
Constructor
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/moneta/adapters/tokyocabinet.rb', line 13 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
33 34 35 36 |
# File 'lib/moneta/adapters/tokyocabinet.rb', line 33 def close @hash.close nil end |
#delete(key, options = {}) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/moneta/adapters/tokyocabinet.rb', line 25 def delete(key, = {}) value = load(key, ) if value @hash.delete(key) value end end |