]> git.saurik.com Git - redis.git/commitdiff
Add function to create ziplist-backed sorted set
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Tue, 8 Mar 2011 15:08:52 +0000 (16:08 +0100)
committerPieter Noordhuis <pcnoordhuis@gmail.com>
Tue, 8 Mar 2011 15:08:52 +0000 (16:08 +0100)
src/object.c
src/redis.h

index e6b02da8ea5747f42708d83f0381b65b98e8aa0e..a6bf8a20560cadf0ab651f73b6c4c1285f502bff 100644 (file)
@@ -93,12 +93,18 @@ robj *createHashObject(void) {
 
 robj *createZsetObject(void) {
     zset *zs = zmalloc(sizeof(*zs));
-
     zs->dict = dictCreate(&zsetDictType,NULL);
     zs->zsl = zslCreate();
     return createObject(REDIS_ZSET,zs);
 }
 
+robj *createZsetZiplistObject(void) {
+    unsigned char *zl = ziplistNew();
+    robj *o = createObject(REDIS_ZSET,zl);
+    o->encoding = REDIS_ENCODING_ZIPLIST;
+    return o;
+}
+
 void freeStringObject(robj *o) {
     if (o->encoding == REDIS_ENCODING_RAW) {
         sdsfree(o->ptr);
index 194032180bc8000846053471f1915b8e10f4e0df..78294d0df78ed82a50341c75b676467037160255 100644 (file)
@@ -730,6 +730,7 @@ robj *createSetObject(void);
 robj *createIntsetObject(void);
 robj *createHashObject(void);
 robj *createZsetObject(void);
+robj *createZsetZiplistObject(void);
 int getLongFromObjectOrReply(redisClient *c, robj *o, long *target, const char *msg);
 int checkType(redisClient *c, robj *o, int type);
 int getLongLongFromObjectOrReply(redisClient *c, robj *o, long long *target, const char *msg);