class Moneta::Memcache
Public Class Methods
new(options = {})
click to toggle source
# File lib/moneta/memcache.rb, line 14 def initialize(options = {}) @cache = MemCache.new(options.delete(:server), options) end
Public Instance Methods
[](key)
click to toggle source
# File lib/moneta/memcache.rb, line 24 def [](key) @cache.get(key) end
[]=(key, value)
click to toggle source
# File lib/moneta/memcache.rb, line 28 def []=(key, value) store(key, value) end
clear()
click to toggle source
# File lib/moneta/memcache.rb, line 48 def clear @cache.flush_all end
delete(key)
click to toggle source
# File lib/moneta/memcache.rb, line 32 def delete(key) value = self[key] @cache.delete(key) if value value end
key?(key)
click to toggle source
# File lib/moneta/memcache.rb, line 18 def key?(key) !self[key].nil? end
Also aliased as: has_key?
store(key, value, options = {})
click to toggle source
# File lib/moneta/memcache.rb, line 38 def store(key, value, options = {}) args = [key, value, options[:expires_in]].compact @cache.set(*args) end
update_key(key, options = {})
click to toggle source
# File lib/moneta/memcache.rb, line 43 def update_key(key, options = {}) val = self[key] self.store(key, val, options) end