Class: LS4::LocalMemoryMDSCache
- Defined in:
- lib/ls4/service/mds_cache_mem.rb
Instance Method Summary collapse
- #close ⇒ Object
- #get(key) ⇒ Object
-
#initialize ⇒ LocalMemoryMDSCache
constructor
A new instance of LocalMemoryMDSCache.
- #invalidate(key) ⇒ Object
- #open(expr) ⇒ Object
- #set(key, val) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ LocalMemoryMDSCache
Returns a new instance of LocalMemoryMDSCache.
24 25 26 |
# File 'lib/ls4/service/mds_cache_mem.rb', line 24 def initialize require 'tokyocabinet' end |
Instance Method Details
#close ⇒ Object
41 42 43 |
# File 'lib/ls4/service/mds_cache_mem.rb', line 41 def close @db.close end |
#get(key) ⇒ Object
45 46 47 |
# File 'lib/ls4/service/mds_cache_mem.rb', line 45 def get(key) @db[key] end |
#invalidate(key) ⇒ Object
53 54 55 |
# File 'lib/ls4/service/mds_cache_mem.rb', line 53 def invalidate(key) @db.delete(key) end |
#open(expr) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ls4/service/mds_cache_mem.rb', line 28 def open(expr) @db = TokyoCabinet::ADB.new if expr.empty? @size = "32m" else @size = expr end name = "+#capsiz=#{@size}" unless @db.open(name) raise "failed to MDS local memory cache database: #{@db.errmsg(@db.ecode)}" end end |
#set(key, val) ⇒ Object
49 50 51 |
# File 'lib/ls4/service/mds_cache_mem.rb', line 49 def set(key, val) @db[key] = val end |
#to_s ⇒ Object
57 58 59 |
# File 'lib/ls4/service/mds_cache_mem.rb', line 57 def to_s "<LocalMemoryMDSCache size=#{@size}>" end |