Sha256: fdae9daa7c2125fbe4f04875cf5fba74d4b3d817ba83779a73344fc9578d16f8

Contents?: true

Size: 353 Bytes

Versions: 26

Compression:

Stored size: 353 Bytes

Contents

require 'rbbt/tsv'
require 'rbbt/persist'
module TCCache
  def self.open(file, type = :single)
    database = Persist.open_tokyocabinet(file, true, type, "HDB")
    database.extend TCCache
  end

  def cache(key)
    if self.include? key
      return self[key]
    else
      self.write_and_read do
        self[key] = yield
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
rbbt-util-5.19.5 lib/rbbt/util/tc_cache.rb
rbbt-util-5.19.4 lib/rbbt/util/tc_cache.rb
rbbt-util-5.19.3 lib/rbbt/util/tc_cache.rb
rbbt-util-5.19.2 lib/rbbt/util/tc_cache.rb
rbbt-util-5.19.1 lib/rbbt/util/tc_cache.rb
rbbt-util-5.19.0 lib/rbbt/util/tc_cache.rb