Commit a9836992 authored by antirez's avatar antirez
Browse files

Use 24 bits for the lru object field and improve resolution.

There were 2 spare bits inside the Redis object structure that are now
used in order to enlarge 4x the range of the LRU field.

At the same time the resolution was improved from 10 to 1 second: this
still provides 194 days before the LRU counter overflows (restarting from
zero).

This is not a problem since it only causes lack of eviction precision for
objects not touched for a very long time, and the lack of precision is
only temporary.
parent f4da796c
...@@ -382,12 +382,11 @@ typedef long long mstime_t; /* millisecond time type. */ ...@@ -382,12 +382,11 @@ typedef long long mstime_t; /* millisecond time type. */
/* A redis object, that is a type able to hold a string / list / set */ /* A redis object, that is a type able to hold a string / list / set */
/* The actual Redis Object */ /* The actual Redis Object */
#define REDIS_LRU_BITS 22 #define REDIS_LRU_BITS 24
#define REDIS_LRU_CLOCK_MAX ((1<<REDIS_LRU_BITS)-1) /* Max value of obj->lru */ #define REDIS_LRU_CLOCK_MAX ((1<<REDIS_LRU_BITS)-1) /* Max value of obj->lru */
#define REDIS_LRU_CLOCK_RESOLUTION 10000 /* LRU clock resolution in ms */ #define REDIS_LRU_CLOCK_RESOLUTION 1000 /* LRU clock resolution in ms */
typedef struct redisObject { typedef struct redisObject {
unsigned type:4; unsigned type:4;
unsigned notused:2; /* Not used */
unsigned encoding:4; unsigned encoding:4;
unsigned lru:REDIS_LRU_BITS; /* lru time (relative to server.lruclock) */ unsigned lru:REDIS_LRU_BITS; /* lru time (relative to server.lruclock) */
int refcount; int refcount;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment