Fix OBJECT IDLETIME return value converting to seconds.

estimateObjectIdleTime() returns a value in milliseconds now, so we need
to scale the output of OBJECT IDLETIME to seconds.
This commit is contained in:
antirez 2014-03-20 11:55:18 +01:00
parent ad6b0f70b2
commit 6d5790d682

View File

@ -648,7 +648,7 @@ char *strEncoding(int encoding) {
} }
} }
/* Given an object returns the min number of seconds the object was never /* Given an object returns the min number of milliseconds the object was never
* requested, using an approximated LRU algorithm. */ * requested, using an approximated LRU algorithm. */
unsigned long long estimateObjectIdleTime(robj *o) { unsigned long long estimateObjectIdleTime(robj *o) {
unsigned long long lruclock = LRU_CLOCK(); unsigned long long lruclock = LRU_CLOCK();
@ -692,7 +692,7 @@ void objectCommand(redisClient *c) {
} else if (!strcasecmp(c->argv[1]->ptr,"idletime") && c->argc == 3) { } else if (!strcasecmp(c->argv[1]->ptr,"idletime") && c->argc == 3) {
if ((o = objectCommandLookupOrReply(c,c->argv[2],shared.nullbulk)) if ((o = objectCommandLookupOrReply(c,c->argv[2],shared.nullbulk))
== NULL) return; == NULL) return;
addReplyLongLong(c,estimateObjectIdleTime(o)); addReplyLongLong(c,estimateObjectIdleTime(o)/1000);
} else { } else {
addReplyError(c,"Syntax error. Try OBJECT (refcount|encoding|idletime)"); addReplyError(c,"Syntax error. Try OBJECT (refcount|encoding|idletime)");
} }