Class: TheCity::CacheAdapter
- Inherits:
-
Object
- Object
- TheCity::CacheAdapter
- Defined in:
- lib/cachers/cache_adapter.rb
Overview
This adapter is the standard for all caching objects.
Direct Known Subclasses
Instance Method Summary collapse
-
#expire_cache!(key) ⇒ Object
Expire the cache.
-
#get_data(key) ⇒ Object
Get the data from the cache.
-
#initialize ⇒ CacheAdapter
constructor
Constructor.
-
#is_cache_expired?(key) ⇒ Boolean
Check if the cache has expired.
-
#save_data(key, data, expire_on = nil) ⇒ Object
Save data to the cache.
Constructor Details
#initialize ⇒ CacheAdapter
Constructor
7 8 |
# File 'lib/cachers/cache_adapter.rb', line 7 def initialize() end |
Instance Method Details
#expire_cache!(key) ⇒ Object
Expire the cache.
-
key The key to use to expire the cache.
36 37 38 |
# File 'lib/cachers/cache_adapter.rb', line 36 def expire_cache!(key) raise 'The expire_cache method must be implemented' end |
#get_data(key) ⇒ Object
Get the data from the cache.
-
key The key to use to get the cache.
Returns the data for the key in the same way it was stored.
28 29 30 |
# File 'lib/cachers/cache_adapter.rb', line 28 def get_data(key) raise 'The get_data method must be implemented' end |
#is_cache_expired?(key) ⇒ Boolean
Check if the cache has expired.
-
key The key to use to check if the cache has expired.
44 45 46 |
# File 'lib/cachers/cache_adapter.rb', line 44 def is_cache_expired?(key) raise 'The is_cache_expired method must be implemented' end |
#save_data(key, data, expire_on = nil) ⇒ Object
Save data to the cache.
-
key The key to use to save the cache.
-
data The JSON data to be saved.
-
expire_on (optional) The datetime to expire the cache.
Returns true on success or a string error message on false.
18 19 20 |
# File 'lib/cachers/cache_adapter.rb', line 18 def save_data(key, data, expire_on = nil) raise 'The save_data method must be implemented' end |