Skip to content

Commit

Permalink
Add lfu support for DEBUG OBJECT command, added lfu_freq and lfu_acce…
Browse files Browse the repository at this point in the history
…ss_time_minutes fields (#479)

For `debug object` command, we use `val->lru` but ignore the `lfu` mode.  
So in `lfu` mode, `debug object` would return meaningless `lru` descriptions. 

Added two new fields lfu_freq and lfu_access_time_minutes.

Signed-off-by: jiangyujie.jyj <yjjiang1996@163.com>
Co-authored-by: Binbin <binloveplay1314@qq.com>
  • Loading branch information
DarrenJiang13 and enjoy-binbin authored Aug 16, 2024
1 parent fc9f291 commit adf53c2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,9 @@ void debugCommand(client *c) {
sds s = sdsempty();
s = sdscatprintf(s, "Value at:%p refcount:%d encoding:%s", (void *)val, val->refcount, strenc);
if (!fast) s = sdscatprintf(s, " serializedlength:%zu", rdbSavedObjectLen(val, c->argv[2], c->db->id));
/* Either lru or lfu field could work correctly which depends on server.maxmemory_policy. */
s = sdscatprintf(s, " lru:%d lru_seconds_idle:%llu", val->lru, estimateObjectIdleTime(val) / 1000);
s = sdscatprintf(s, " lfu_freq:%lu lfu_access_time_minutes:%u", LFUDecrAndReturn(val), val->lru >> 8);
s = sdscatprintf(s, "%s", extra);
addReplyStatusLength(c, s, sdslen(s));
sdsfree(s);
Expand Down

0 comments on commit adf53c2

Please sign in to comment.