redis2.6+版本,redis.conf中的默认的策略是 noeviction ,一共有八种:
# volatile-lru -> Evict using approximated LRU among the keys with an expire set.
# allkeys-lru -> Evict any key using approximated LRU.
# volatile-lfu -> Evict using approximated LFU among the keys with an expire set.
# allkeys-lfu -> Evict any key using approximated LFU.
# volatile-random -> Remove a random key among the ones with an expire set.
# allkeys-random -> Remove a random key, any key.
# volatile-ttl -> Remove the key with the nearest expire time (minor TTL)
# noeviction -> Don't evict anything, just return an error on write operations.
1、volatile-lru:只对设置了过期时间的key进行LRU算法进行删除
2、allkeys-lru : 对所有key执行LRU算法进行删除
3、volatile-lfu:只对设置了过期时间的key进行LFU算法进行删除
4、allkeys-lfu:对所有key执行LFU算法进行删除
5、volatile-random:随机删除设置有过期时间的key
6、allkeys-random:随机删除
7、volatile-ttl : 删除即将过期的
8、noeviction : 永不过期,返回错误
redis2.6及以前的版本,redis.conf中的默认的策略是 volatile-lru,一共有六种:
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key accordingly to the LRU algorithm
# volatile-random -> remove a random key with an expire set
# allkeys-random -> remove a random key, any key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# noeviction -> don't expire at all, just return an error on write operations
1、volatile-lru:只对设置了过期时间的key进行LRU算法进行删除
2、allkeys-lru : 对所有key执行LRU算法进行删除
3、volatile-random:随机删除设置有过期时间的key
4、allkeys-random:随机删除
5、volatile-ttl : 删除即将过期的
6、noeviction : 永不过期,返回错误
PS:
LRU(least recently used)最近最少使用
LFU(least frequently used )最少经常使用