watson.cache.storage¶
-
class
watson.cache.storage.
BaseStorage
(config=None)[source]¶ Base class for all cache storage classes.
Cache storage classes are designed to act similar to a dict, however get and set methods can be used when a timeout is required on a set, or when a default value is to be specified on a get.
-
config
¶ dict – The relevant configuration settings for the storage.
-
expired
(key)[source]¶ Determine if a key has expired or not.
Parameters: key (string) – The key to find Returns: True/False depending on expiration Return type: Boolean
-
-
class
watson.cache.storage.
File
(config=None)[source]¶ A cache storage mechanism for storing items on the local filesystem.
File cache storage will persist the data to the filesystem in whichever directory has been specified in the configuration options. If no directory is specified then the system temporary folder will be used.
-
__init__
(config=None)[source]¶ Initializes the cache.
Parameters: config (dict) – The config for the cache Example:
cache = File({'dir': '/tmp', 'prefix': 'my-cache'}) # all cached items will be saved to /tmp # and will be prefixed with my-cache cache['key'] = 'value' # /tmp/my-cache-key contains a serialized 'value'
-
-
class
watson.cache.storage.
Memcached
(config=None)[source]¶ A cache storage mechanism for storing items in memcached.
Memcached cache storage will utilize python3-memcached to maintain the cache across multiple servers. Python3-memcached documentation can be found at http://pypi.python.org/pypi/python3-memcached/
-
class
watson.cache.storage.
Memory
[source]¶ A cache storage mechanism for storing items in memory.
Memory cache storage will maintain the cache while the application is being run. This is usually best used in instances when you don’t want to keep the cached items after the application has finished running.
-
class
watson.cache.storage.
Redis
(config=None)[source]¶ A cache storage mechanism for storing items in redis.
Redis cache storage will utilize redis to maintain the cache across multiple servers. redis documentation can be found at https://github.com/andymccurdy/redis-py