Bases: object
Base Cache Abstraction
Params parsed_url: | |
---|---|
Parsed url object. |
|
Params options: | A dictionary with configuration parameters for the cache. For example:
|
Appends value to key‘s value.
Params key: | The key of the value to which tail should be appended. |
---|---|
Params value: | The value to append to the original. |
Returns: | The new value |
Appends tail to key‘s value.
Params key: | The key of the value to which tail should be appended. |
---|---|
Params tail: | The list of values to append to the original. |
Returns: | The new value |
Removes all items from the cache.
Note
Thread-safety is required and it has to be guaranteed by the backend implementation.
Gets one item from the cache
Note
Thread-safety is required and it has to be guaranteed by the backend implementation.
Params key: | Key for the item to retrieve from the cache. |
---|---|
Params default: | The default value to return. |
Returns: | key‘s value in the cache if it exists, otherwise default should be returned. |
Gets keys’ value from cache
Params keys: | List of keys to retrieve. |
---|---|
Params default: | The default value to return for each key that is not in the cache. |
Returns: | A generator of (key, value) |
Increments the value for a key
Params key: | The key for the value to be incremented |
---|---|
Params delta: | Number of units by which to increment the value. Pass a negative number to decrement the value. |
Returns: | The new value |
Sets or updates a cache entry
Note
Thread-safety is required and has to be guaranteed by the backend implementation.
Params key: | Item key as string. |
---|---|
Params value: | Value to assign to the key. This can be anything that is handled by the current backend. |
Params ttl: | Key’s timeout in seconds. 0 means no timeout. |
Params not_exists: | |
If True, the key will be set if it doesn’t exist. Otherwise, it’ll always be set. | |
Returns: | True if the operation succeeds, False otherwise. |
Puts several items into the cache at once
Depending on the backend, this operation may or may not be efficient. The default implementation calls set for each (key, value) pair passed, other backends support set_many operations as part of their protocols.
Params data: | A dictionary like {key: val} to store in the cache. |
---|---|
Params ttl: | Key’s timeout in seconds. |
Sets the key value to value if it doesn’t exist
Params key: | Item key as string. |
---|---|
Params value: | Value to assign to the key. This can be anything that is handled by the current backend. |
Removes several keys from the cache at once
Params keys: | List of keys to unset. |
---|
Sets several (key, value) paris.
Refer to the set_many docstring.