Class: Flare::Tools::Cli::Dump::TchDumper
- Defined in:
- lib/flare/tools/cli/dump.rb
Instance Attribute Summary
Attributes inherited from Dumper
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(filepath) ⇒ TchDumper
constructor
A new instance of TchDumper.
- #write(data, key, flag, size, version, expire) ⇒ Object
Constructor Details
#initialize(filepath) ⇒ TchDumper
Returns a new instance of TchDumper.
81 82 83 84 85 86 |
# File 'lib/flare/tools/cli/dump.rb', line 81 def initialize filepath raise "output file not specified." if filepath.nil? raise "#{filepath} isn't a path." unless filepath.kind_of?(String) @hdb = TokyoCabinet::HDB.new @hdb.open(filepath, TokyoCabinet::HDB::OCREAT|TokyoCabinet::HDB::OWRITER) end |
Class Method Details
.myname ⇒ Object
78 79 80 |
# File 'lib/flare/tools/cli/dump.rb', line 78 def self.myname "tch" end |
Instance Method Details
#close ⇒ Object
96 97 98 |
# File 'lib/flare/tools/cli/dump.rb', line 96 def close @hdb.close end |
#write(data, key, flag, size, version, expire) ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/flare/tools/cli/dump.rb', line 87 def write data, key, flag, size, version, expire # uint32_t flag -> L // uint32_t # time_t expire -> Q // unsigned long # uint64_t size -> Q // uint64_t # uint64_t version -> Q // uint64_t # uint32_t option -> L // uint32_t value = [flag, expire, size, version].pack("LQQQ")+data @hdb.put(key, value) end |