diff options
author | antirez <antirez@gmail.com> | 2014-07-18 10:09:51 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-07-18 10:09:51 +0200 |
commit | b3c042cdb2acfd9d33c8820763f9156789dc97ee (patch) | |
tree | 60d27084c3d9ca50b92fc20614efa38229f0395a /src | |
parent | 27839e5ecb562d9b79e740e2e20f7a6db7270a66 (diff) | |
download | redis-b3c042cdb2acfd9d33c8820763f9156789dc97ee.tar.gz |
tryObjectEncoding(): use shared objects with maxmemory and non-LRU policy.
In order to make sure every object has its own private LRU counter, when
maxmemory is enabled tryObjectEncoding() does not use the pool of shared
integers. However when the policy is not LRU-based, it does not make
sense to do so, and it is much better to save memory using shared
integers.
Diffstat (limited to 'src')
-rw-r--r-- | src/object.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/object.c b/src/object.c index 2cf9e04fd..6b8e42477 100644 --- a/src/object.c +++ b/src/object.c @@ -373,7 +373,9 @@ robj *tryObjectEncoding(robj *o) { * Note that we avoid using shared integers when maxmemory is used * because every object needs to have a private LRU field for the LRU * algorithm to work well. */ - if (server.maxmemory == 0 && + if ((server.maxmemory == 0 || + (server.maxmemory_policy != REDIS_MAXMEMORY_VOLATILE_LRU && + server.maxmemory_policy != REDIS_MAXMEMORY_ALLKEYS_LRU)) && value >= 0 && value < REDIS_SHARED_INTEGERS) { |