Commit f199504a authored by antirez's avatar antirez
Browse files

Modules: ZSET API WIP.

parent 11b3df24
...@@ -145,6 +145,9 @@ int moduleCreateEmtpyKey(RedisModuleKey *key, int type) { ...@@ -145,6 +145,9 @@ int moduleCreateEmtpyKey(RedisModuleKey *key, int type) {
quicklistSetOptions(obj->ptr, server.list_max_ziplist_size, quicklistSetOptions(obj->ptr, server.list_max_ziplist_size,
server.list_compress_depth); server.list_compress_depth);
break; break;
case REDISMODULE_KEYTYPE_ZSET:
obj = createZsetZiplistObject();
break;
default: return REDISMODULE_ERR; default: return REDISMODULE_ERR;
} }
dbAdd(key->db,key->key,obj); dbAdd(key->db,key->key,obj);
...@@ -805,7 +808,6 @@ int RM_ListPush(RedisModuleKey *key, int where, RedisModuleString *ele) { ...@@ -805,7 +808,6 @@ int RM_ListPush(RedisModuleKey *key, int where, RedisModuleString *ele) {
if (key->value->type != OBJ_LIST) return REDISMODULE_ERR; if (key->value->type != OBJ_LIST) return REDISMODULE_ERR;
listTypePush(key->value, ele, listTypePush(key->value, ele,
(where == REDISMODULE_LIST_HEAD) ? QUICKLIST_HEAD : QUICKLIST_TAIL); (where == REDISMODULE_LIST_HEAD) ? QUICKLIST_HEAD : QUICKLIST_TAIL);
signalModifiedKey(key->db,key->key);
return REDISMODULE_OK; return REDISMODULE_OK;
} }
...@@ -829,6 +831,17 @@ RedisModuleString *RM_ListPop(RedisModuleKey *key, int where) { ...@@ -829,6 +831,17 @@ RedisModuleString *RM_ListPop(RedisModuleKey *key, int where) {
return decoded; return decoded;
} }
/* --------------------------------------------------------------------------
* Key API for Sorted Set type
* -------------------------------------------------------------------------- */
int RM_ZsetAdd(RedisModuleKey *key, double score, RedisModuleString *ele) {
if (!(key->mode & REDISMODULE_WRITE)) return REDISMODULE_ERR;
if (key->value == NULL) moduleCreateEmtpyKey(key,REDISMODULE_KEYTYPE_ZSET);
if (key->value->type != OBJ_ZSET) return REDISMODULE_ERR;
return REDISMODULE_OK;
}
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
* Redis <-> Modules generic Call() API * Redis <-> Modules generic Call() API
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
......
...@@ -634,10 +634,6 @@ Work in progress. ...@@ -634,10 +634,6 @@ Work in progress.
Work in progress. Work in progress.
## Accessing keys TTL and setting expires
Work in progress.
# Replicating commands # Replicating commands
If you want to use module commands exactly like normal Redis commands, in the If you want to use module commands exactly like normal Redis commands, in the
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment