Skip to content

Add documentation about redis cache configuration #14683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions components/cache/adapters/redis_adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ In order to use tag-based invalidation, you can wrap your adapter in :class:`Sym
$client = RedisAdapter::createConnection('redis://localhost');
$cache = new RedisTagAwareAdapter($client);

Configuring Redis
~~~~~~~~~~~~~~~~~

When using Redis as cache, you should configure the `maxmemory` and `maxmemory-policy` settings.
Read more about this topic in the offical `Redis LRU Cache Documentation`_.
By setting `maxmemory`, you limit how much memory Redis is allowed to consume. If the amount is too low, Redis will drop entries that would still be useful and you benefit less from your cache. Setting the `maxmemory-policy` to
`allkeys-lru` tells Redis that it is ok to drop data when it runs out of memory, and to first drop the oldest entries (least
recently used). If you do not allow Redis to drop entries, it will return an error when you try to add data when no
memory is available. An example setting could look as follows:

maxmemory 100mb
maxmemory-policy allkeys-lru

.. _`Data Source Name (DSN)`: https://en.wikipedia.org/wiki/Data_source_name
.. _`Redis server`: https://redis.io/
Expand All @@ -211,3 +223,4 @@ In order to use tag-based invalidation, you can wrap your adapter in :class:`Sym
.. _`Predis Connection Parameters`: https://github.com/nrk/predis/wiki/Connection-Parameters#list-of-connection-parameters
.. _`TCP-keepalive`: https://redis.io/topics/clients#tcp-keepalive
.. _`Redis Sentinel`: https://redis.io/topics/sentinel
.. _`Redis LRU Cache Documentation`: https://redis.io/topics/lru-cache