Class: ActionController::Caching::Fragments::UnthreadedMemCacheFragmentStore
- Inherits:
-
Object
- Object
- ActionController::Caching::Fragments::UnthreadedMemCacheFragmentStore
- Defined in:
- lib/mem_cache_fragment_store.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#ttl ⇒ Object
Returns the value of attribute ttl.
Instance Method Summary collapse
- #delete(name, options = nil) ⇒ Object
- #delete_matched(matcher, options = nil) ⇒ Object
-
#initialize(cache, ttl = 0) ⇒ UnthreadedMemCacheFragmentStore
constructor
A new instance of UnthreadedMemCacheFragmentStore.
- #read(name, options = nil) ⇒ Object
- #write(name, value, options = nil) ⇒ Object
Constructor Details
#initialize(cache, ttl = 0) ⇒ UnthreadedMemCacheFragmentStore
Returns a new instance of UnthreadedMemCacheFragmentStore.
10 11 12 13 |
# File 'lib/mem_cache_fragment_store.rb', line 10 def initialize(cache, ttl = 0) @data = cache @ttl = ttl end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
7 8 9 |
# File 'lib/mem_cache_fragment_store.rb', line 7 def data @data end |
#ttl ⇒ Object
Returns the value of attribute ttl.
8 9 10 |
# File 'lib/mem_cache_fragment_store.rb', line 8 def ttl @ttl end |
Instance Method Details
#delete(name, options = nil) ⇒ Object
27 28 29 30 31 |
# File 'lib/mem_cache_fragment_store.rb', line 27 def delete(name, = nil) @data.delete "fragment:#{name}" rescue MemCache::MemCacheError => err handle_error err end |
#delete_matched(matcher, options = nil) ⇒ Object
33 34 35 36 |
# File 'lib/mem_cache_fragment_store.rb', line 33 def delete_matched(matcher, = nil) return nil unless ActionController::Base.logger ActionController::Base.logger.error "MemCacheFragmentStore#delete_matched is not supported" end |
#read(name, options = nil) ⇒ Object
15 16 17 18 19 |
# File 'lib/mem_cache_fragment_store.rb', line 15 def read(name, = nil) @data.get "fragment:#{name}" rescue MemCache::MemCacheError => err handle_error err end |
#write(name, value, options = nil) ⇒ Object
21 22 23 24 25 |
# File 'lib/mem_cache_fragment_store.rb', line 21 def write(name, value, = nil) @data.set "fragment:#{name}", value, @ttl rescue MemCache::MemCacheError => err handle_error err end |