Class: Juno::Adapters::TokyoCabinet
- Defined in:
- lib/juno/adapters/tokyocabinet.rb
Overview
TokyoCabinet backend
Instance Method Summary collapse
- #close ⇒ Object
- #delete(key, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ TokyoCabinet
constructor
Constructor.
- #key?(key, options = {}) ⇒ Boolean
Methods inherited from Memory
Methods inherited from Base
Constructor Details
#initialize(options = {}) ⇒ TokyoCabinet
Constructor
Options:
-
:file - Database file
-
:type - Database type (default :hdb, :bdb and :hdb possible)
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/juno/adapters/tokyocabinet.rb', line 15 def initialize( = {}) file = [:file] raise ArgumentError, 'Option :file is required' unless [:file] if [:type] == :bdb @memory = ::TokyoCabinet::BDB.new @memory.open(file, ::TokyoCabinet::BDB::OWRITER | ::TokyoCabinet::BDB::OCREAT) else @memory = ::TokyoCabinet::HDB.new @memory.open(file, ::TokyoCabinet::HDB::OWRITER | ::TokyoCabinet::HDB::OCREAT) end or raise @memory.errmsg(@memory.ecode) end |
Instance Method Details
#close ⇒ Object
39 40 41 42 |
# File 'lib/juno/adapters/tokyocabinet.rb', line 39 def close @memory.close nil end |
#delete(key, options = {}) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/juno/adapters/tokyocabinet.rb', line 31 def delete(key, = {}) value = load(key, ) if value @memory.delete(key) value end end |
#key?(key, options = {}) ⇒ Boolean
27 28 29 |
# File 'lib/juno/adapters/tokyocabinet.rb', line 27 def key?(key, = {}) !!load(key, ) end |