Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding expiration feature * Back to 100% * Missed a branch * Adding feature to readme * First pass at generic backend * Fixing tests * Updating cache * Moving file to __init__.py and changing Backends * Comments
- Loading branch information
Alex Kahan
committed
Oct 14, 2016
1 parent
217c271
commit b172c7b
Showing
11 changed files
with
270 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
class Backend(object): | ||
""" | ||
Generic backend base class. Provides an interface to use the cache | ||
with any backend | ||
""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
pass | ||
|
||
def get_cache(self, key): | ||
""" | ||
Gets the given key from the cache backend | ||
:param key: The cache key to get | ||
:return: The value in the cache in the case of a cache hit, | ||
otherwise None | ||
""" | ||
raise NotImplementedError() | ||
|
||
def set_cache(self, key, value): | ||
""" | ||
Sets the given key/value pair in the cache backend | ||
:param key: The cache key | ||
:param value: The cache value | ||
:return: Response from cache backend | ||
""" | ||
raise NotImplementedError() | ||
|
||
def set_cache_and_expire(self, key, value, expiration): | ||
""" | ||
Sets the key/value pair in the cache backend with an expiration TTL | ||
:param key: The cache key | ||
:param value: The cache value | ||
:param expiration: The time to live (ttl) in seconds | ||
:return: Response from cache backend | ||
""" | ||
raise NotImplementedError() | ||
|
||
def invalidate_key(self, key): | ||
""" | ||
Removes the key from the cache | ||
:param key: The cache key | ||
:return: Response from cache Backend | ||
""" | ||
raise NotImplementedError() | ||
|
||
|
||
class BackendException(Exception): | ||
""" | ||
Cache backend exception | ||
""" | ||
pass |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.