Class: ActiveCachedResource::CachingStrategies::Base
- Inherits:
-
Object
- Object
- ActiveCachedResource::CachingStrategies::Base
- Defined in:
- lib/active_cached_resource/caching_strategies/base.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#clear(pattern) ⇒ Boolean
Clears the cache based on the given pattern.
-
#delete(key) ⇒ void
Deletes the cached value associated with the given key.
-
#read(key) ⇒ Object?
Reads the value associated with the given key from the cache.
-
#write(key, value, options) ⇒ Boolean
Writes an object to the cache with the specified key and options.
Instance Method Details
#clear(pattern) ⇒ Boolean
Clears the cache based on the given pattern.
44 45 46 |
# File 'lib/active_cached_resource/caching_strategies/base.rb', line 44 def clear(pattern) clear_raw(pattern) end |
#delete(key) ⇒ void
This method returns an undefined value.
Deletes the cached value associated with the given key.
35 36 37 |
# File 'lib/active_cached_resource/caching_strategies/base.rb', line 35 def delete(key) delete_raw(hash_key(key)) end |
#read(key) ⇒ Object?
Reads the value associated with the given key from the cache.
9 10 11 12 13 |
# File 'lib/active_cached_resource/caching_strategies/base.rb', line 9 def read(key) raise ArgumentError, "key must be a String or Symbol" unless key.is_a?(String) || key.is_a?(Symbol) raw_value = read_raw(hash_key(key)) raw_value && decompress(raw_value) end |
#write(key, value, options) ⇒ Boolean
Writes an object to the cache with the specified key and options.
25 26 27 28 29 |
# File 'lib/active_cached_resource/caching_strategies/base.rb', line 25 def write(key, value, ) raise ArgumentError, "`expires_in` option is required" unless [:expires_in] write_raw(hash_key(key), compress(value), ) end |