module TCCache
Public Class Methods
Source
# File lib/rbbt/util/tc_cache.rb, line 4 def self.open(file, type = :single) database = Persist.open_tokyocabinet(file, true, type, "HDB") database.extend TCCache end
Public Instance Methods
Source
# File lib/rbbt/util/tc_cache.rb, line 9 def cache(key) self.read_and_close do return self[key] if self.include? key end value = yield self.write_and_close do self[key] = value end value end