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.
-
#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.
37 38 39 |
# File 'lib/active_cached_resource/caching_strategies/base.rb', line 37 def clear(pattern) clear_raw(pattern) end |
#read(key) ⇒ Object?
Reads the value associated with the given key from the cache.
10 11 12 13 14 |
# File 'lib/active_cached_resource/caching_strategies/base.rb', line 10 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.
26 27 28 29 30 |
# File 'lib/active_cached_resource/caching_strategies/base.rb', line 26 def write(key, value, ) raise ArgumentError, "`expires_in` option is required" unless [:expires_in] write_raw(hash_key(key), compress(value), ) end |