英文:
Eviction policy with lua for redis
问题
有没有办法将自定义的Lua脚本设置为Redis的淘汰策略?我已经查阅了文档和一些其他来源,但还没有找到相关信息。
英文:
Is there a way to set a custom lua script as the eviction policy for Redis?
I have searched around the documentation and some other sources but i haven't found anything yet.
答案1
得分: 0
noeviction
: 不会在达到内存限制时保存新值。当数据库使用复制时,这适用于主数据库。
allkeys-lru
: 保留最近使用的键;删除最不常使用的键(LRU算法)。
allkeys-lfu
: 保留频繁使用的键;删除最不频繁使用的键(LFU算法)。
volatile-lru
: 删除带有到期字段设置为true的最近不常使用的键。
volatile-lfu
: 删除带有到期字段设置为true的最不频繁使用的键。
allkeys-random
: 随机删除键以为新添加的数据腾出空间。
volatile-random
: 随机删除带有到期字段设置为true的键。
volatile-ttl
: 删除带有到期字段设置为true且剩余的存活时间(TTL)最短的键。
英文:
No this is not possible. Redis eviction policies are set in the configuration file maxmemory-policy
(see https://redis.io/docs/reference/eviction/) and include, quoting from the documentation:
noeviction
: New values aren’t saved when memory limit is reached. When a database uses replication, this applies to the primary databaseallkeys-lru
: Keeps most recently used keys; removes least recently used (LRU) keys- allkeys-lfu: Keeps frequently used keys; removes least frequently used (LFU) keys
volatile-lru
: Removes least recently used keys with the expire field set to true.volatile-lfu
: Removes least frequently used keys with the expire field set to true.allkeys-random
: Randomly removes keys to make space for the new data added.volatile-random
: Randomly removes keys with expire field set to true.volatile-ttl
: Removes keys with expire field set to true and the shortest remaining time-to-live (TTL) value.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论