summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-08-27 11:52:12 +0200
committerantirez <antirez@gmail.com>2013-08-27 12:51:45 +0200
commite5fe66efe9f9b67ce6f9d06f919645756a588d6f (patch)
tree306272a853f046ea517cadf08ce7b54097392d0a
parent7bf2690043901086ddb9a8ce77e428764190de3c (diff)
downloadredis-e5fe66efe9f9b67ce6f9d06f919645756a588d6f.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.
-rw-r--r--src/debug.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/debug.c b/src/debug.c
index d8898b42a..3af9bdb89 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -294,6 +294,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;