Specify LRU resolution in milliseconds.

This commit is contained in:
antirez 2014-03-20 11:33:25 +01:00
parent a8127d9fcb
commit 2f5a67dbca
4 changed files with 4 additions and 5 deletions

View File

@ -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));

View File

@ -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 {

View File

@ -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;

View File

@ -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<<REDIS_LRU_BITS)-1) /* Max value of obj->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 */