Skip to content

Commit 78dd1cd

Browse files
committed
minor symfony#14683 Add documentation about redis cache configuration (alexander-schranz)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- Add documentation about redis cache configuration Add documentation about redis cache configuration. I personally did run into issue that my cache did explode and I didn't know why. At the end old cache entries where never thrown [away](doctrine/DoctrinePHPCRBundle#349 (comment)). This can easily be fixed by configuring redis with a maxmemory and maxmemory-policy. So the server will not run into having to much RAM usage. Commits ------- 8e2e7de Add documentation about redis cache configuration
2 parents dab151b + 8e2e7de commit 78dd1cd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

components/cache/adapters/redis_adapter.rst

+13
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)