Redis supports lru cache algorithm using two configurable directives, maxmemory and maxmemory-policy, which can be set in redis.conf file.
Setting maxmemory to zero means there is no limitation for redis memory. If maxmemory-policy is set to noeviction, no keys will be evicted while memory reaches the limitation, redis just returns error to client that is trying to add more data to the server. For other maxmemory-policy options, redis will select appropriate keys to evict, meaning the evicted keys will be deleted from memory, requests to read these keys will get a nil response.
So this reminds us if we use redis as a permanent store such as user info database, maxmemory-policy should be set to noeviction to guarantee that no data will be lost. Or if we use redis just as a data cache, we can use maxmemory along with maxmemory-policy to evict those least recently used keys.