Eviction policy with lua for redis 缓存淘汰策略使用 Lua 脚本来实现。

huangapple go评论54阅读模式
英文:

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 database
  • allkeys-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.

huangapple
  • 本文由 发表于 2023年4月13日 22:33:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76006685.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定