diff options
author | antirez <antirez@gmail.com> | 2013-08-27 11:52:12 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2013-08-27 11:53:49 +0200 |
commit | e21803348a1c707c5fe36524a589b2475d5ad791 (patch) | |
tree | 3210343ea8fdb1fb80b99b5a23b74943115defed /src/debug.c | |
parent | b34126e37850f70d55ee441a54e28be18e9141c4 (diff) | |
download | redis-e21803348a1c707c5fe36524a589b2475d5ad791.tar.gz |
DEBUG SDSLEN added.
This command is only useful for low-level debugging of memory issues due
to sds wasting memory as empty buffer at the end of the string.
Diffstat (limited to 'src/debug.c')
-rw-r--r-- | src/debug.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/debug.c b/src/debug.c index a0352b5dd..e8e16cc8b 100644 --- a/src/debug.c +++ b/src/debug.c @@ -296,6 +296,29 @@ void debugCommand(redisClient *c) { (void*)val, val->refcount, strenc, (long long) rdbSavedObjectLen(val), val->lru, estimateObjectIdleTime(val)); + } else if (!strcasecmp(c->argv[1]->ptr,"sdslen") && c->argc == 3) { + dictEntry *de; + robj *val; + sds key; + + if ((de = dictFind(c->db->dict,c->argv[2]->ptr)) == NULL) { + addReply(c,shared.nokeyerr); + return; + } + val = dictGetVal(de); + key = dictGetKey(de); + + if (val->type != REDIS_STRING || !sdsEncodedObject(val)) { + addReplyError(c,"Not an sds encoded string."); + } else { + addReplyStatusFormat(c, + "key_sds_len:%lld, key_sds_avail:%lld, " + "val_sds_len:%lld, val_sds_avail:%lld", + (long long) sdslen(key), + (long long) sdsavail(key), + (long long) sdslen(val->ptr), + (long long) sdsavail(val->ptr)); + } } else if (!strcasecmp(c->argv[1]->ptr,"populate") && c->argc == 3) { long keys, j; robj *key, *val; |