Obtain LRU clock in a resolution dependent way.

For testing purposes it is handy to have a very high resolution of the
LRU clock, so that it is possible to experiment with scripts running in
just a few seconds how the eviction algorithms works.

This commit allows Redis to use the cached LRU clock, or a value
computed on demand, depending on the resolution. So normally we have the
good performance of a precomputed value, and a clock that wraps in many
days using the normal resolution, but if needed, changing a define will
switch behavior to an high resolution LRU clock.
This commit is contained in:
antirez
2014-03-20 11:47:12 +01:00
parent 1faf82663f
commit ad6b0f70b2
4 changed files with 25 additions and 19 deletions

View File

@ -50,7 +50,7 @@ robj *lookupKey(redisDb *db, robj *key) {
* Don't do it if we have a saving child, as this will trigger
* a copy on write madness. */
if (server.rdb_child_pid == -1 && server.aof_child_pid == -1)
val->lru = server.lruclock;
val->lru = LRU_CLOCK();
return val;
} else {
return NULL;