redis缓存过期策略设置
1 2 3 4 5 6 7 8 9 10 11 12 |
一般缓存过期策略配合最大内存设置来使用: maxmemory 2mb 【如果用set方式来写,必须写字节数,比如1k = 1000,1m = 1000000】 maxmemory-policy allkeys-lru 【缓存满了后的清理策略】 lru有6种过期策略 # volatile-lru -> remove the key with an expire set using an LRU algorithm 从已设置过期时间的数据集(server.db[i].expires)中挑选最近最少使用的数据淘汰 # allkeys-lru -> remove any key accordingly to the LRU algorithm 从数据集(server.db[i].dict)中挑选最近最少使用的数据淘汰 # volatile-random -> remove a random key with an expire set 从已设置过期时间的数据集(server.db[i].expires)中任意选择数据淘汰 # allkeys-random -> remove a random key, any key 从数据集(server.db[i].dict)中任意选择数据淘汰 # volatile-ttl -> remove the key with the nearest expire time (minor TTL) 从已设置过期时间的数据集(server.db[i].expires)中挑选将要过期的数据淘汰 # noeviction -> don't expire at all, just return 禁止驱逐数据 更深层次的请阅读:http://blog.sae.sina.com.cn/archives/4045 |
噢!评论已关闭。