Search code examples
redisazure-redis-cache

What happens in Redis cache with Volatile-LRU maxmemory policy when memory get filled?


I have a redis cache in Azure with maxmemory policy set as Volatile-LRU. When writing to Redis, I am not adding an expiry time for the key. In this case, what will happen when the cache memory get filled?


Solution

  • Under the volatile-lru policy, redis will never evict a key without a expiry. If all of memory is used up by keys that do not have expiry set then the next time you use a command that requires allocating more memory than is available, say SET, the command will fail and you will get this error message:

    OOM command not allowed when used memory > 'maxmemory'
    

    You will still be able to use commands that don't allocate memory, like GET. If you get your database into this state, you can use the EXPIRE command to set and expiry time on keys after the fact.