有关redis做cache优化

公司redis一直是用来做cache缓存的,如果不对其做优化,默认淘汰机制,在内存使用达到上限后会出现各种命令报错。
官方如下描述
noeviction: return errors when the memory limit was reached and the client is trying to execute commands that could result in more memory to be used (most write commands, but DEL and a few more exceptions).

既然作为cache就需要做优化
在线修改
登陆
##***:6379>
CONFIG SET SAVE " " 关闭本地持久化
CONFIG SET maxmemory 10G 使用最大内存(结合实际内存资源)
CONFIG SET maxmemory-policy "allkeys-lru" 设置达到最大内存后的淘汰机制

官方对淘汰机制的描述。
allkeys-lru: evict keys by trying to remove the less recently used (LRU) keys first, in order to make space for the new data added.

有关其他的优化以及淘汰机制选择请参考官方
https://redis.io/topics/lru-cache

猜你喜欢

转载自blog.51cto.com/12102819/2416382
今日推荐