Sha256: 3225a44f5d04f3e6354d7e6aad4a8b6e98b3147a5c6c128cde8a8d3205f51e14

Contents?: true

Size: 889 Bytes

Versions: 16

Compression:

Stored size: 889 Bytes

Contents

require 'tokyocabinet'
module Monkeyshines
  module Store
    #
    # Implementation of KeyStore with a Local TokyoCabinet table database (TDB)
    #
    class TokyoTdbKeyStore < Monkeyshines::Store::KeyStore

      # pass in the filename or URI of a tokyo cabinet table-style DB
      # set create_db = true if you want to create a missing DB file
      def initialize db_uri, *args
        self.db = TokyoCabinet::TDB.new
        db.open(db_uri, TokyoCabinet::TDB::OWRITER) or raise "#{self.class.to_s}: Can't open TokyoCabinet TDB #{db_uri}"
        super *args
      end


      def each_as klass, &block
        self.each do |key, hsh|
          yield klass.from_hash hsh
        end
      end
      # Delegate to store
      def set(key, val)
        return unless val
        db.put key, val.to_hash.compact
      end

      def size()        db.rnum  end

    end #class
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
wukong-3.0.0.pre old/wukong/store/tokyo_tdb_key_store.rb
wukong-2.0.2 lib/wukong/store/tokyo_tdb_key_store.rb
wukong-2.0.1 lib/wukong/store/tokyo_tdb_key_store.rb
wukong-2.0.0 lib/wukong/store/tokyo_tdb_key_store.rb
wukong-1.5.4 lib/wukong/store/tokyo_tdb_key_store.rb
wukong-1.5.3 lib/wukong/store/tokyo_tdb_key_store.rb
wukong-1.5.2 lib/wukong/store/tokyo_tdb_key_store.rb
wukong-1.5.1 lib/wukong/store/tokyo_tdb_key_store.rb
wukong-1.5.0 lib/wukong/store/tokyo_tdb_key_store.rb
wukong-1.4.12 lib/wukong/store/tokyo_tdb_key_store.rb
wukong-1.4.11 lib/wukong/store/tokyo_tdb_key_store.rb
monkeyshines-0.2.3 lib/monkeyshines/store/tokyo_tdb_key_store.rb
monkeyshines-0.2.2 lib/monkeyshines/store/tokyo_tdb_key_store.rb
monkeyshines-0.2.1 lib/monkeyshines/store/tokyo_tdb_key_store.rb
monkeyshines-0.2.0 lib/monkeyshines/store/tokyo_tdb_key_store.rb
monkeyshines-0.0.2 lib/monkeyshines/store/tokyo_tdb_key_store.rb