gpt4 book ai didi

redis - 哪些 maxmemory 策略允许在 Redis 中过期?

转载 作者:IT王子 更新时间:2023-10-29 06:11:36 26 4
gpt4 key购买 nike

哪些 maxmemory 策略与 redis 过期机制兼容?

它只是volatile-ttl吗? noeviction 会阻止旧记录死亡吗?

最佳答案

从这里查看redis.conf :

MAXMEMORY POLICY: how Redis will select what to remove when maxmemory is reached. You can select among five behaviors:

volatile-lru -> remove the key with an expire set using an LRU algorithm

allkeys-lru -> remove any key according 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

Note: with any of the above policies, Redis will return an error on write operations, when there are no suitable keys for eviction.

  At the date of writing these commands are: set setnx setex append
incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
getset mset msetnx exec sort

The default is:

maxmemory-policy noeviction

如果您将政策保持在默认的“noeviction”,或者如果您选择任何 volatile-* 政策,而实际上数据库中没有过期键,数据将无限期地保留在 Redis 中。但是请记住,如果您不从 Redis 中删除数据并继续添加更多数据,您最终会耗尽内存。

关于redis - 哪些 maxmemory 策略允许在 Redis 中过期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30239588/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com