| 1 |
Contributed Cache Backends |
| 2 |
-------------------------- |
| 3 |
|
| 4 |
.. warning:: |
| 5 |
The backends in this section were contributed by users of Flask-Caching. |
| 6 |
They are not officially supported: this project does not guarantee that |
| 7 |
they are maintained, tested or functional at any given time. Use at your |
| 8 |
own risk. |
| 9 |
|
| 10 |
Unlike the built-in backends, these cannot be selected by their class name |
| 11 |
alone. Set ``CACHE_TYPE`` to the full import path of the class. |
| 12 |
|
| 13 |
|
| 14 |
.. _googlecloudstoragecache: |
| 15 |
|
| 16 |
GoogleCloudStorageCache |
| 17 |
``````````````````````` |
| 18 |
|
| 19 |
Set ``CACHE_TYPE`` to |
| 20 |
``flask_caching.contrib.googlecloudstoragecache.GoogleCloudStorageCache`` to |
| 21 |
use this type. Uses a Google Cloud Storage bucket as a cache backend. The |
| 22 |
``google-cloud-storage`` package is required. |
| 23 |
|
| 24 |
Relevant configuration values |
| 25 |
|
| 26 |
- CACHE_DEFAULT_TIMEOUT |
| 27 |
- CACHE_KEY_PREFIX |
| 28 |
- CACHE_ARGS |
| 29 |
- CACHE_OPTIONS |
| 30 |
|
| 31 |
``CACHE_GCS_BUCKET`` is required and is the name of the bucket to use. The |
| 32 |
bucket must already exist. |
| 33 |
|
| 34 |
The following entries in CACHE_OPTIONS are recognised, any others are passed |
| 35 |
to ``google.cloud.storage.Client`` as ``**kwargs`` |
| 36 |
|
| 37 |
*delete_expired_objects_on_read* |
| 38 |
If ``True``, a read that finds a stale object deletes it before returning |
| 39 |
a response. This slows down responses. Defaults to ``False``. |
| 40 |
|
| 41 |
*anonymous* |
| 42 |
If ``True``, use anonymous credentials. Useful for testing. Defaults to |
| 43 |
``False``. |
| 44 |
|
| 45 |
.. note:: |
| 46 |
Cache keys must be valid GCS object names, that is a sequence of Unicode |
| 47 |
characters whose UTF-8 encoding is at most 1024 bytes long. |
| 48 |
|
| 49 |
.. note:: |
| 50 |
Expired cache objects are not purged automatically. Unless |
| 51 |
*delete_expired_objects_on_read* is enabled, stale objects have to be |
| 52 |
deleted out of band, for example with a bucket lifecycle rule:: |
| 53 |
|
| 54 |
{"rule": [{"action": {"type": "Delete"}, |
| 55 |
"condition": {"daysSinceCustomTime": 0}}]} |
| 56 |
|
| 57 |
See `Object Lifecycle Management |
| 58 |
<https://cloud.google.com/storage/docs/lifecycle#dayssincecustomtime>`_. |
| 59 |
|
| 60 |
.. versionadded:: 1.10.1 |
| 61 |
|
| 62 |
|
| 63 |
.. _uwsgicache: |
| 64 |
|
| 65 |
UWSGICache |
| 66 |
`````````` |
| 67 |
|
| 68 |
Set ``CACHE_TYPE`` to ``flask_caching.contrib.uwsgicache.UWSGICache`` to use |
| 69 |
this type. You also have to set ``CACHE_UWSGI_NAME`` to the cache name you |
| 70 |
set in your uWSGI configuration. |
| 71 |
|
| 72 |
Relevant configuration values |
| 73 |
|
| 74 |
- CACHE_DEFAULT_TIMEOUT |
| 75 |
- CACHE_IGNORE_ERRORS |
| 76 |
- CACHE_UWSGI_NAME |
| 77 |
|
| 78 |
.. note:: |
| 79 |
This backend cannot be used when running under PyPy, because the uWSGI API |
| 80 |
implementation for PyPy is lacking the needed functionality. |
| 81 |
|
| 82 |
.. versionchanged:: 1.10.0 |
| 83 |
Moved to the user contributed backends. |