Skip to content

Commit 8e2e7de

Browse files
alexander-schranzOskarStark
authored andcommitted
Add documentation about redis cache configuration
1 parent dab151b commit 8e2e7de

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

components/cache/adapters/redis_adapter.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,18 @@ In order to use tag-based invalidation, you can wrap your adapter in :class:`Sym
201201
$client = RedisAdapter::createConnection('redis://localhost');
202202
$cache = new RedisTagAwareAdapter($client);
203203

204+
Configuring Redis
205+
~~~~~~~~~~~~~~~~~
206+
207+
When using Redis as cache, you should configure the `maxmemory` and `maxmemory-policy` settings.
208+
Read more about this topic in the offical `Redis LRU Cache Documentation`_.
209+
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
210+
`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
211+
recently used). If you do not allow Redis to drop entries, it will return an error when you try to add data when no
212+
memory is available. An example setting could look as follows:
213+
214+
maxmemory 100mb
215+
maxmemory-policy allkeys-lru
204216

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

0 commit comments

Comments
 (0)