提交 7d4c2a98 编写于 作者: M Matt Stancliff

Add maxmemory_policy to INFO output

Also refactors getting human string values from
the defined value in `server.maxmemory_policy`
into a common function.
上级 3cd36a4d
......@@ -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)) {
......
......@@ -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
);
}
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册