From ae696e5e1b15a77af7c9ee61746a066c6fc60aee Mon Sep 17 00:00:00 2001 From: "chenyangyang.cy" Date: Sat, 14 Aug 2021 22:14:58 +0800 Subject: [PATCH] Optimize active timer code --- src/tairhash.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tairhash.c b/src/tairhash.c index 26db065..babb4a5 100755 --- a/src/tairhash.c +++ b/src/tairhash.c @@ -421,6 +421,11 @@ void activeExpireTimerHandler(RedisModuleCtx *ctx, void *data) { continue; } + if (RedisModule_DbSize(ctx) == 0) { + current_db++; + continue; + } + int expire_keys_per_loop = tair_hash_active_expire_keys_per_loop; list *keys = m_listCreate(); @@ -536,8 +541,6 @@ void activeExpireTimerHandler(RedisModuleCtx *ctx, void *data) { } if (start_index) { - size_t len; - const char * ptr = RedisModule_StringPtrLen(key, &len); m_zslDeleteRangeByRank(tair_hash_obj->expire_index, 1, start_index); delEmptyTairHashIfNeeded(ctx, real_key, key, tair_hash_obj); } @@ -968,7 +971,7 @@ int tairHashExpireGenericFunc(RedisModuleCtx *ctx, RedisModuleString **argv, int RedisModule_ReplyWithLongLong(ctx, 1); tair_hash_val->version += 1; - + if (ex_flags & TAIR_HASH_SET_WITH_ABS_VER) { tair_hash_val->version = version; }