Commit b3c042cd authored by antirez's avatar antirez
Browse files

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.
parent 27839e5e
...@@ -373,7 +373,9 @@ robj *tryObjectEncoding(robj *o) { ...@@ -373,7 +373,9 @@ robj *tryObjectEncoding(robj *o) {
* Note that we avoid using shared integers when maxmemory is used * Note that we avoid using shared integers when maxmemory is used
* because every object needs to have a private LRU field for the LRU * because every object needs to have a private LRU field for the LRU
* algorithm to work well. */ * 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 >= 0 &&
value < REDIS_SHARED_INTEGERS) value < REDIS_SHARED_INTEGERS)
{ {
......
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