Only override maxmemory settings if everything is default

Former-commit-id: 9fb240d49c61f5a69124a17cfc769095cadd3d98
This commit is contained in:
John Sully 2019-12-20 18:19:24 -05:00
parent 448b1093cd
commit afce86838e

View File

@ -229,14 +229,13 @@ static bool initializeStorageProvider(sds *argv, int argc, const char **err)
if (fResult) if (fResult)
{ {
// We need to set max memory to a sane default so keys are actually evicted properly // We need to set max memory to a sane default so keys are actually evicted properly
if (g_pserver->maxmemory == 0) if (g_pserver->maxmemory == 0 && g_pserver->maxmemory_policy == MAXMEMORY_NO_EVICTION)
{ {
struct sysinfo sys; struct sysinfo sys;
if (sysinfo(&sys) == 0) if (sysinfo(&sys) == 0)
{ {
// By default it's half the memory. This gives sufficient room for background saving // By default it's half the memory. This gives sufficient room for background saving
g_pserver->maxmemory = sys.totalram / 2; g_pserver->maxmemory = sys.totalram / 2;
if (g_pserver->maxmemory_policy == MAXMEMORY_NO_EVICTION)
g_pserver->maxmemory_policy = MAXMEMORY_ALLKEYS_LRU; g_pserver->maxmemory_policy = MAXMEMORY_ALLKEYS_LRU;
} }
} }