redis缓存策略解析

# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory

# is reached. You can select among five behaviors:

#

# volatile-lru -> Evict using approximated LRU among the keys with an expire set.

 最近最少使用,使用LRU算法移除key,只对设置了过期时间的键


# allkeys-lru -> Evict any key using approximated LRU. 

使用LRU算法移除key


# 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.

在过期的集合中移除随机的key,只对设置了过期时间的键


# allkeys-random -> Remove a random key, any key.

移除随机的key


# volatile-ttl -> Remove the key with the nearest expire time (minor TTL)

移除那些TTL值最小的Key,即那些最近要过期的key


# noeviction -> Don't evict anything, just return an error on write operations.

 不进行移除,针对写操作,只是返回错误信息

#

# LRU means Least Recently Used

# LFU means Least Frequently Used

#

# Both LRU, LFU and volatile-ttl are implemented using approximated

# randomized algorithms.



持久化:rdb  aof

Rdb:在指定的时间间隔内将内存中的数据集快照写入磁盘

 snapshot快照,恢复时是将快照文件直接读到内存中

优点:适合大规模的数据恢复

     对数据完整性和一致性要求不高

劣势:

    在一定时间间隔做一次备份,所以如果redis意外down掉的话,就会丢失最后一次快照后的所有修改

   fork的时候,内存中的数据被克隆了一份,大致2杯的膨胀性需要考虑


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值