您的当前位置:首页 >应用开发 >阅读 Redis 源码,学习缓存淘汰算法 W-TinyLFU 正文

阅读 Redis 源码,学习缓存淘汰算法 W-TinyLFU

时间:2025-11-04 21:01:36 来源:网络整理编辑:应用开发

核心提示

复制intprocessCommand(redisClient*c){ ...... /*Handlethemaxmemorydirective.

阅读 Redis 源码,学习缓存淘汰算法 W-TinyLFU
复制int processCommand(redisClient *c) {      ......      /* Handle the maxmemory directive.       *       * First we try tofreesome memory if possible (if there are volatile       * keys in the dataset). If there are not the only thing we can do       * is returning an error. */      if (server.maxmemory) {          int retval = freeMemoryIfNeeded();          if ((c->cmd->flags & REDIS_CMD_DENYOOM) && retval == REDIS_ERR) {              flagTransaction(c);              addReply(c,阅读s源 shared.oomerr);              return REDIS_OK;          }      }      ......  }  1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.