How do I set the maximum memory size that Redis can use?

You can do that using maxmemory option: maxmemory 314572800 means 300mb.


maxmemory is the correct configuration option to prevent Redis from using too much RAM.

If an insert causes maxmemory to be exceeded, the insert operation will sometimes fail.

Redis will do everything in its power to prevent the operation from failing, though. In the newer versions of Redis, you can configure the memory reclaiming policies in the configuration, as well by setting the maxmemory-policy option.

Also, if you have virtual memory options turned on, Redis will begin to store stale data to the disk.

More info:

  • What does Redis do when it runs out of memory?

Tags:

Nosql

Redis