Class: LS4::MemcacheMDS
Defined Under Namespace
Instance Method Summary collapse
- #add(key, attrs = {}, vname = nil, &cb) ⇒ Object
- #close ⇒ Object
- #delete(key, version = nil, &cb) ⇒ Object
- #get_attrs(key, version = nil, &cb) ⇒ Object
- #get_okey(key, version = nil, &cb) ⇒ Object
- #get_okey_attrs(key, version = nil, &cb) ⇒ Object
-
#initialize ⇒ MemcacheMDS
constructor
A new instance of MemcacheMDS.
- #open(expr) ⇒ Object
- #remove(key, &cb) ⇒ Object
- #update_attrs(key, attrs, &cb) ⇒ Object
Methods inherited from MDS
Constructor Details
#initialize ⇒ MemcacheMDS
Returns a new instance of MemcacheMDS.
40 41 42 |
# File 'lib/ls4/service/mds_memcache.rb', line 40 def initialize require 'memcache' end |
Instance Method Details
#add(key, attrs = {}, vname = nil, &cb) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/ls4/service/mds_memcache.rb', line 85 def add(key, attrs={}, vname=nil, &cb) okey = set_impl(key, attrs, vname) cb.call(okey, nil) rescue nil rescue cb.call(nil, $!) rescue nil end |
#close ⇒ Object
48 49 50 |
# File 'lib/ls4/service/mds_memcache.rb', line 48 def close @hadb.close end |
#delete(key, version = nil, &cb) ⇒ Object
122 123 124 125 |
# File 'lib/ls4/service/mds_memcache.rb', line 122 def delete(key, version=nil, &cb) raise "version is not supported on memcache MDS" if version remove(key, &cb) end |
#get_attrs(key, version = nil, &cb) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ls4/service/mds_memcache.rb', line 63 def get_attrs(key, version=nil, &cb) e = get_impl(key, version) if e cb.call(e.attrs, nil) rescue nil else cb.call(nil, nil) rescue nil end rescue cb.call(nil, $!) rescue nil end |
#get_okey(key, version = nil, &cb) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ls4/service/mds_memcache.rb', line 52 def get_okey(key, version=nil, &cb) e = get_impl(key, version) if e cb.call(e.to_okey(key), nil) rescue nil else cb.call(nil, nil) rescue nil end rescue cb.call(nil, $!) rescue nil end |
#get_okey_attrs(key, version = nil, &cb) ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ls4/service/mds_memcache.rb', line 74 def get_okey_attrs(key, version=nil, &cb) e = get_impl(key, version) if e cb.call([e.to_okey(key), e.attrs], nil) rescue nil else cb.call(nil, nil) rescue nil end rescue cb.call(nil, $!) rescue nil end |
#open(expr) ⇒ Object
44 45 46 |
# File 'lib/ls4/service/mds_memcache.rb', line 44 def open(expr) @hadb = HADB.new(expr) end |
#remove(key, &cb) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/ls4/service/mds_memcache.rb', line 101 def remove(key, &cb) e = get_impl(key) if e result = nil @hadb.write(key) {|mc| result = mc.delete(key) } #if result !~ /DELETED/ # TODO #end cb.call(e.to_okey(key), nil) rescue nil else cb.call(nil, nil) rescue nil end rescue cb.call(nil, $!) rescue nil end |
#update_attrs(key, attrs, &cb) ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/ls4/service/mds_memcache.rb', line 92 def update_attrs(key, attrs, &cb) okey = update_impl(key) {|old_attrs| attrs } cb.call(okey, nil) rescue nil rescue cb.call(nil, $!) rescue nil end |