Class: MemCacheStore

Inherits:
Memoize::Storable show all
Defined in:
lib/memoize.rb

Instance Attribute Summary collapse

Attributes inherited from Memoize::Storable

#store

Instance Method Summary collapse

Methods inherited from Memoize::Storable

#update

Constructor Details

#initialize(name) ⇒ MemCacheStore

Returns a new instance of MemCacheStore.



272
273
274
275
# File 'lib/memoize.rb', line 272

def initialize(name)
  @keys   = []
  @cache  = MemCache.new 'localhost:11211', :namespace => 'rakuto.blogspot.com'
end

Instance Attribute Details

#cacheObject

Returns the value of attribute cache.



271
272
273
# File 'lib/memoize.rb', line 271

def cache
  @cache
end

#keysObject

Returns the value of attribute keys.



271
272
273
# File 'lib/memoize.rb', line 271

def keys
  @keys
end

Instance Method Details

#delete(key) ⇒ Object



286
287
288
# File 'lib/memoize.rb', line 286

def delete(key)
  @cache.delete(key)
end

#delete_allObject



290
291
292
# File 'lib/memoize.rb', line 290

def delete_all
  @keys.each { |key| @cache.delete(key) }
end

#get(key) ⇒ Object



277
278
279
# File 'lib/memoize.rb', line 277

def get(key)
  @cache.get(key)
end

#set(key, value) ⇒ Object



281
282
283
284
# File 'lib/memoize.rb', line 281

def set(key, value)
  @keys << key unless @keys.include?(key)
  @cache.set(key, value)
end