diff --git a/src/config.c b/src/config.c index 05cb7c9fe..2140b769f 100644 --- a/src/config.c +++ b/src/config.c @@ -1004,6 +1004,20 @@ badfmt: /* Bad format errors */ } \ } while(0); +char *maxmemoryToString() { + char *s; + switch(server.maxmemory_policy) { + case REDIS_MAXMEMORY_VOLATILE_LRU: s = "volatile-lru"; break; + case REDIS_MAXMEMORY_VOLATILE_TTL: s = "volatile-ttl"; break; + case REDIS_MAXMEMORY_VOLATILE_RANDOM: s = "volatile-random"; break; + case REDIS_MAXMEMORY_ALLKEYS_LRU: s = "allkeys-lru"; break; + case REDIS_MAXMEMORY_ALLKEYS_RANDOM: s = "allkeys-random"; break; + case REDIS_MAXMEMORY_NO_EVICTION: s = "noeviction"; break; + default: s = "unknown"; break; + } + return s; +} + void configGetCommand(redisClient *c) { robj *o = c->argv[2]; void *replylen = addDeferredMultiBulkLength(c); @@ -1112,19 +1126,8 @@ void configGetCommand(redisClient *c) { matches++; } if (stringmatch(pattern,"maxmemory-policy",0)) { - char *s; - - switch(server.maxmemory_policy) { - case REDIS_MAXMEMORY_VOLATILE_LRU: s = "volatile-lru"; break; - case REDIS_MAXMEMORY_VOLATILE_TTL: s = "volatile-ttl"; break; - case REDIS_MAXMEMORY_VOLATILE_RANDOM: s = "volatile-random"; break; - case REDIS_MAXMEMORY_ALLKEYS_LRU: s = "allkeys-lru"; break; - case REDIS_MAXMEMORY_ALLKEYS_RANDOM: s = "allkeys-random"; break; - case REDIS_MAXMEMORY_NO_EVICTION: s = "noeviction"; break; - default: s = "unknown"; break; /* too harmless to panic */ - } addReplyBulkCString(c,"maxmemory-policy"); - addReplyBulkCString(c,s); + addReplyBulkCString(c,maxmemoryToString()); matches++; } if (stringmatch(pattern,"appendfsync",0)) { diff --git a/src/redis.c b/src/redis.c index 030cfbb48..08a06e4f7 100644 --- a/src/redis.c +++ b/src/redis.c @@ -2699,6 +2699,7 @@ sds genRedisInfoString(char *section) { char hmem[64]; char peak_hmem[64]; size_t zmalloc_used = zmalloc_used_memory(); + char *evict_policy = maxmemoryToString(); /* Peak memory is updated from time to time by serverCron() so it * may happen that the instantaneous value is slightly bigger than @@ -2719,7 +2720,8 @@ sds genRedisInfoString(char *section) { "used_memory_peak_human:%s\r\n" "used_memory_lua:%lld\r\n" "mem_fragmentation_ratio:%.2f\r\n" - "mem_allocator:%s\r\n", + "mem_allocator:%s\r\n" + "maxmemory_policy:%s\r\n", zmalloc_used, hmem, server.resident_set_size, @@ -2727,7 +2729,8 @@ sds genRedisInfoString(char *section) { peak_hmem, ((long long)lua_gc(server.lua,LUA_GCCOUNT,0))*1024LL, zmalloc_get_fragmentation_ratio(server.resident_set_size), - ZMALLOC_LIB + ZMALLOC_LIB, + evict_policy ); } diff --git a/src/redis.h b/src/redis.h index 88cbe2f94..53a93f00a 100644 --- a/src/redis.h +++ b/src/redis.h @@ -1255,6 +1255,7 @@ void closeListeningSockets(int unlink_unix_socket); void updateCachedTime(void); void resetServerStats(void); unsigned int getLRUClock(void); +char *maxmemoryToString(void); /* Set data type */ robj *setTypeCreate(robj *value);