Class: TheCity::CacheAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/cachers/cache_adapter.rb

Overview

This adapter is the standard for all caching objects.

Direct Known Subclasses

JsonCache

Instance Method Summary collapse

Constructor Details

#initializeCacheAdapter

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.

Returns:

  • (Boolean)


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