If you want to use Redis as a cache and all keys have an expiration time, you might consider using the following settings (assuming a maximum memory usage of 2M):
maxmemory 2mbmaxmemory-policy allkeys-lru
The above settings do not require our app to use the expire (or similar command) command to set the expiration time for each key, because some keys are automatically deleted using the class LRU algorithm as long as memory usage reaches 2m,redis.
Using cache settings is a more efficient way to use memory than to store the expiration time of multiple keys with extra memory space. It is also a more recommended way to use LRU than when each key is fixed, because it allows the application's hot data (more frequently used keys) to stay in memory longer.
Redis is basically configured so that it can be used as a memcached.
When we use Redis as a cache, it is highly recommended to use two Redis instances if the application also needs to use Redis as a storage system. One is the cache, which is configured using the above method, the other is storage, is configured according to the application's persistence requirements, and only the data that does not need to be cached is stored.
Original: http://www.redis.cn/topics/config.html
Redis is used only as a cache configuration