Answer the question
In order to leave comments, you need to log in
'maxmemory'." in Redis/PHP?" />
How to avoid "OOM command not allowed when used memory > 'maxmemory'." in Redis/PHP?
There is a Redis docker service, which is used as an LRU cache. The volume of one record is approximately up to 100Kb.
Service memory is severely limited to 64mb. you don’t need more, and all records are stored for only a minute and then they are simply not needed.
In some particularly active moments, when the memory is full, an OOM command not allowed when used memory > 'maxmemory' exception occurs.
I perfectly understand what it means and why it occurs. But I just can’t get Redis to simply clear the old keys and enter new ones so that everything is without exceptions.
Tell me, what settings should I set for him so that he correctly clears the old keys? Saving to disk is disabled and not needed. All keys with expires
Now run like this (docker-compose):
redis_cache:
mem_limit: 64m
image: redis:4.0-alpine
command: "redis-server --port 6379 --timeout 0 --save \"\" --appendonly no --maxclients 1000000 --maxmemory 60m --maxmemory-policy allkeys-lru --maxmemory-samples 50"
Answer the question
In order to leave comments, you need to log in
No way. Redis, unlike Memcache, guarantees the safety of data. Those. you set TTL for recording and it will be stored exactly as long as specified in the TTL value. Memcached replaces the old data if there is not enough memory for the new portion, regardless of the TTL.
I'm currently investigating the same issue, and according to https://ma.ttias.be/redis-oom-command-not-allowed-... the required behavior can still be achieved.
In fact, under the conditions given in the question, it should be enough to change the parameter
on the
After that, of course, restart Redis.
I draw your attention to the fact that if Redis contains data that cannot be lost, then the method will not work, but with the correct settings for flushing data to disk, the risk of data loss will be minimal.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question