Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
f199504a
Commit
f199504a
authored
Apr 14, 2016
by
antirez
Browse files
Modules: ZSET API WIP.
parent
11b3df24
Changes
2
Show whitespace changes
Inline
Side-by-side
src/module.c
View file @
f199504a
...
@@ -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
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
...
...
src/modules/API.md
View file @
f199504a
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment