diff --git a/src/debug.c b/src/debug.c index 5068c4836..a9c7cc5e7 100644 --- a/src/debug.c +++ b/src/debug.c @@ -292,7 +292,7 @@ void debugCommand(redisClient *c) { addReplyStatusFormat(c, "Value at:%p refcount:%d " "encoding:%s serializedlength:%lld " - "lru:%d lru_seconds_idle:%lu", + "lru:%d lru_seconds_idle:%llu", (void*)val, val->refcount, strenc, (long long) rdbSavedObjectLen(val), val->lru, estimateObjectIdleTime(val)); diff --git a/src/object.c b/src/object.c index d6efcd8c2..775a0dd50 100644 --- a/src/object.c +++ b/src/object.c @@ -650,7 +650,7 @@ char *strEncoding(int encoding) { /* Given an object returns the min number of seconds the object was never * requested, using an approximated LRU algorithm. */ -unsigned long estimateObjectIdleTime(robj *o) { +unsigned long long estimateObjectIdleTime(robj *o) { if (server.lruclock >= o->lru) { return (server.lruclock - o->lru) * REDIS_LRU_CLOCK_RESOLUTION; } else { diff --git a/src/redis.c b/src/redis.c index da70266c5..b8ed87325 100644 --- a/src/redis.c +++ b/src/redis.c @@ -844,11 +844,10 @@ void activeExpireCycle(int type) { } void updateLRUClock(void) { - server.lruclock = (server.unixtime/REDIS_LRU_CLOCK_RESOLUTION) & + server.lruclock = (mstime()/REDIS_LRU_CLOCK_RESOLUTION) & REDIS_LRU_CLOCK_MAX; } - /* Add a sample to the operations per second array of samples. */ void trackOperationsPerSecond(void) { long long t = mstime() - server.ops_sec_last_sample_time; diff --git a/src/redis.h b/src/redis.h index 6d07653bb..efa13107d 100644 --- a/src/redis.h +++ b/src/redis.h @@ -384,7 +384,7 @@ typedef long long mstime_t; /* millisecond time type. */ /* The actual Redis Object */ #define REDIS_LRU_BITS 22 #define REDIS_LRU_CLOCK_MAX ((1<lru */ -#define REDIS_LRU_CLOCK_RESOLUTION 10 /* LRU clock resolution in seconds */ +#define REDIS_LRU_CLOCK_RESOLUTION 10000 /* LRU clock resolution in ms */ typedef struct redisObject { unsigned type:4; unsigned notused:2; /* Not used */