Class: MemCacheStore
- Inherits:
-
Memoize::Storable
- Object
- Memoize::Storable
- MemCacheStore
- Defined in:
- lib/memoize.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#keys ⇒ Object
Returns the value of attribute keys.
Attributes inherited from Memoize::Storable
Instance Method Summary collapse
- #delete(key) ⇒ Object
- #delete_all ⇒ Object
- #get(key) ⇒ Object
-
#initialize(name) ⇒ MemCacheStore
constructor
A new instance of MemCacheStore.
- #set(key, value) ⇒ Object
Methods inherited from Memoize::Storable
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
#cache ⇒ Object
Returns the value of attribute cache.
271 272 273 |
# File 'lib/memoize.rb', line 271 def cache @cache end |
#keys ⇒ Object
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_all ⇒ Object
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 |