From 13a49af44b11dc275654a461f7d7ba5c20e27c1a Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 15 Oct 2010 18:04:05 +0200 Subject: [PATCH] prevent small integer sharing when maxmemory is active. So every object will use a private LRU field and the LRU algorithm can work well --- src/object.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/object.c b/src/object.c index bba44824..b1eae963 100644 --- a/src/object.c +++ b/src/object.c @@ -245,8 +245,12 @@ robj *tryObjectEncoding(robj *o) { * range and if this is the main thread, since when VM is enabled we * have the constraint that I/O thread should only handle non-shared * objects, in order to avoid race conditions (we don't have per-object - * locking). */ - if (value >= 0 && value < REDIS_SHARED_INTEGERS && + * locking). + * + * Note that we also avoid using shared integers when maxmemory is used + * because very object needs to have a private LRU field for the LRU + * algorithm to work well. */ + if (server.maxmemory == 0 && value >= 0 && value < REDIS_SHARED_INTEGERS && pthread_equal(pthread_self(),server.mainthread)) { decrRefCount(o); incrRefCount(shared.integers[value]); -- 2.45.2