Configuring memory policy
As an in-memory data store, Redis uses more memory space than databases that always persist data to disk. Although nowadays the cost of memory is lower, it is still necessary to budget the memory space for Redis in the production environment. In addition, as Redis is often used as a cache, besides setting timeout values to make keys expire automatically, we also need to consider the conviction policy when the cache is full. In this recipe, we will introduce two important memory configuration options in Redis with examples.
Getting ready…
You need to finish the installation of the Redis Server, as we described in the Downloading and installing Redis recipe in Chapter 1, Getting Started with Redis.
How to do it...
The steps for configuring memory policies are as follows:
- To get the current memory usage, use
INFO MEMORY
:
127.0.0.1:6379> INFO MEMORY
# Memory
used_memory:836848
used_memory_human:817.23K
used_memory_rss:10174464
used_memory_rss_human:9.70M
used_memory_peak...