Skip to content

Commit

Permalink
Optimize active timer code
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyang8094 committed Aug 14, 2021
1 parent afeab55 commit ae696e5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/tairhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit ae696e5

Please sign in to comment.