redis 源码阅读之 redis.c

Misc

      /* Resize */
        for (j = 0; j < dbs_per_call; j++) {
            tryResizeHashTables(resize_db % server.dbnum);
            resize_db++;
        }

        /* Rehash */
        if (server.activerehashing) {
            for (j = 0; j < dbs_per_call; j++) {
                int work_done = incrementallyRehash(rehash_db % server.dbnum);
                rehash_db++;
                if (work_done) {
                    /* If the function did some work, stop here, we'll do
                     * more at the next cron loop. */
                    break;
                }
            }
        }

这段代码很奇怪, tryResizeHashTables 会创建 ht[1] 字典。 如果 server.activerhashing 配置为 0 。则不会 rehash, 那么在 tryResizeHashTable 中的新分配的 ht[1] 字典是不是就浪费了?

猜你喜欢

转载自www.cnblogs.com/tmortred/p/12969590.html
今日推荐