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
75b41de8
Commit
75b41de8
authored
Oct 17, 2010
by
Pieter Noordhuis
Browse files
Convert objects in the command procs instead of the protocol code
parent
b19c33d4
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/aof.c
View file @
75b41de8
...
@@ -266,9 +266,6 @@ int loadAppendOnlyFile(char *filename) {
...
@@ -266,9 +266,6 @@ int loadAppendOnlyFile(char *filename) {
redisLog
(
REDIS_WARNING
,
"Unknown command '%s' reading the append only file"
,
argv
[
0
]
->
ptr
);
redisLog
(
REDIS_WARNING
,
"Unknown command '%s' reading the append only file"
,
argv
[
0
]
->
ptr
);
exit
(
1
);
exit
(
1
);
}
}
/* Try object encoding */
if
(
cmd
->
flags
&
REDIS_CMD_BULK
)
argv
[
argc
-
1
]
=
tryObjectEncoding
(
argv
[
argc
-
1
]);
/* Run the command in the context of a fake client */
/* Run the command in the context of a fake client */
fakeClient
->
argc
=
argc
;
fakeClient
->
argc
=
argc
;
fakeClient
->
argv
=
argv
;
fakeClient
->
argv
=
argv
;
...
...
src/config.c
View file @
75b41de8
...
@@ -410,6 +410,7 @@ void configGetCommand(redisClient *c) {
...
@@ -410,6 +410,7 @@ void configGetCommand(redisClient *c) {
}
}
void
configCommand
(
redisClient
*
c
)
{
void
configCommand
(
redisClient
*
c
)
{
c
->
argv
[
c
->
argc
-
1
]
=
tryObjectEncoding
(
c
->
argv
[
c
->
argc
-
1
]);
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"set"
))
{
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"set"
))
{
if
(
c
->
argc
!=
4
)
goto
badarity
;
if
(
c
->
argc
!=
4
)
goto
badarity
;
configSetCommand
(
c
);
configSetCommand
(
c
);
...
...
src/pubsub.c
View file @
75b41de8
...
@@ -262,6 +262,7 @@ void punsubscribeCommand(redisClient *c) {
...
@@ -262,6 +262,7 @@ void punsubscribeCommand(redisClient *c) {
}
}
void
publishCommand
(
redisClient
*
c
)
{
void
publishCommand
(
redisClient
*
c
)
{
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
int
receivers
=
pubsubPublishMessage
(
c
->
argv
[
1
],
c
->
argv
[
2
]);
int
receivers
=
pubsubPublishMessage
(
c
->
argv
[
1
],
c
->
argv
[
2
]);
addReplyLongLong
(
c
,
receivers
);
addReplyLongLong
(
c
,
receivers
);
}
}
src/redis.c
View file @
75b41de8
...
@@ -914,10 +914,6 @@ int processCommand(redisClient *c) {
...
@@ -914,10 +914,6 @@ int processCommand(redisClient *c) {
return
REDIS_OK
;
return
REDIS_OK
;
}
}
/* Let's try to encode the bulk object to save space. */
if
(
cmd
->
flags
&
REDIS_CMD_BULK
)
c
->
argv
[
c
->
argc
-
1
]
=
tryObjectEncoding
(
c
->
argv
[
c
->
argc
-
1
]);
/* Check if the user is authenticated */
/* Check if the user is authenticated */
if
(
server
.
requirepass
&&
!
c
->
authenticated
&&
cmd
->
proc
!=
authCommand
)
{
if
(
server
.
requirepass
&&
!
c
->
authenticated
&&
cmd
->
proc
!=
authCommand
)
{
addReplyError
(
c
,
"operation not permitted"
);
addReplyError
(
c
,
"operation not permitted"
);
...
@@ -1011,6 +1007,7 @@ void pingCommand(redisClient *c) {
...
@@ -1011,6 +1007,7 @@ void pingCommand(redisClient *c) {
}
}
void
echoCommand
(
redisClient
*
c
)
{
void
echoCommand
(
redisClient
*
c
)
{
c
->
argv
[
1
]
=
tryObjectEncoding
(
c
->
argv
[
1
]);
addReplyBulk
(
c
,
c
->
argv
[
1
]);
addReplyBulk
(
c
,
c
->
argv
[
1
]);
}
}
...
...
src/t_hash.c
View file @
75b41de8
...
@@ -220,6 +220,7 @@ void hsetCommand(redisClient *c) {
...
@@ -220,6 +220,7 @@ void hsetCommand(redisClient *c) {
robj
*
o
;
robj
*
o
;
if
((
o
=
hashTypeLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
if
((
o
=
hashTypeLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
hashTypeTryConversion
(
o
,
c
->
argv
,
2
,
3
);
hashTypeTryConversion
(
o
,
c
->
argv
,
2
,
3
);
hashTypeTryObjectEncoding
(
o
,
&
c
->
argv
[
2
],
&
c
->
argv
[
3
]);
hashTypeTryObjectEncoding
(
o
,
&
c
->
argv
[
2
],
&
c
->
argv
[
3
]);
update
=
hashTypeSet
(
o
,
c
->
argv
[
2
],
c
->
argv
[
3
]);
update
=
hashTypeSet
(
o
,
c
->
argv
[
2
],
c
->
argv
[
3
]);
...
@@ -231,6 +232,7 @@ void hsetCommand(redisClient *c) {
...
@@ -231,6 +232,7 @@ void hsetCommand(redisClient *c) {
void
hsetnxCommand
(
redisClient
*
c
)
{
void
hsetnxCommand
(
redisClient
*
c
)
{
robj
*
o
;
robj
*
o
;
if
((
o
=
hashTypeLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
if
((
o
=
hashTypeLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
hashTypeTryConversion
(
o
,
c
->
argv
,
2
,
3
);
hashTypeTryConversion
(
o
,
c
->
argv
,
2
,
3
);
if
(
hashTypeExists
(
o
,
c
->
argv
[
2
]))
{
if
(
hashTypeExists
(
o
,
c
->
argv
[
2
]))
{
...
@@ -254,6 +256,7 @@ void hmsetCommand(redisClient *c) {
...
@@ -254,6 +256,7 @@ void hmsetCommand(redisClient *c) {
}
}
if
((
o
=
hashTypeLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
if
((
o
=
hashTypeLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
c
->
argv
[
c
->
argc
-
1
]
=
tryObjectEncoding
(
c
->
argv
[
c
->
argc
-
1
]);
hashTypeTryConversion
(
o
,
c
->
argv
,
2
,
c
->
argc
-
1
);
hashTypeTryConversion
(
o
,
c
->
argv
,
2
,
c
->
argc
-
1
);
for
(
i
=
2
;
i
<
c
->
argc
;
i
+=
2
)
{
for
(
i
=
2
;
i
<
c
->
argc
;
i
+=
2
)
{
hashTypeTryObjectEncoding
(
o
,
&
c
->
argv
[
i
],
&
c
->
argv
[
i
+
1
]);
hashTypeTryObjectEncoding
(
o
,
&
c
->
argv
[
i
],
&
c
->
argv
[
i
+
1
]);
...
@@ -296,6 +299,7 @@ void hgetCommand(redisClient *c) {
...
@@ -296,6 +299,7 @@ void hgetCommand(redisClient *c) {
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nullbulk
))
==
NULL
||
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nullbulk
))
==
NULL
||
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
if
((
value
=
hashTypeGet
(
o
,
c
->
argv
[
2
]))
!=
NULL
)
{
if
((
value
=
hashTypeGet
(
o
,
c
->
argv
[
2
]))
!=
NULL
)
{
addReplyBulk
(
c
,
value
);
addReplyBulk
(
c
,
value
);
decrRefCount
(
value
);
decrRefCount
(
value
);
...
@@ -316,6 +320,7 @@ void hmgetCommand(redisClient *c) {
...
@@ -316,6 +320,7 @@ void hmgetCommand(redisClient *c) {
* done because objects that cannot be found are considered to be
* done because objects that cannot be found are considered to be
* an empty hash. The reply should then be a series of NULLs. */
* an empty hash. The reply should then be a series of NULLs. */
addReplyMultiBulkLen
(
c
,
c
->
argc
-
2
);
addReplyMultiBulkLen
(
c
,
c
->
argc
-
2
);
c
->
argv
[
c
->
argc
-
1
]
=
tryObjectEncoding
(
c
->
argv
[
c
->
argc
-
1
]);
for
(
i
=
2
;
i
<
c
->
argc
;
i
++
)
{
for
(
i
=
2
;
i
<
c
->
argc
;
i
++
)
{
if
(
o
!=
NULL
&&
(
value
=
hashTypeGet
(
o
,
c
->
argv
[
i
]))
!=
NULL
)
{
if
(
o
!=
NULL
&&
(
value
=
hashTypeGet
(
o
,
c
->
argv
[
i
]))
!=
NULL
)
{
addReplyBulk
(
c
,
value
);
addReplyBulk
(
c
,
value
);
...
@@ -331,6 +336,7 @@ void hdelCommand(redisClient *c) {
...
@@ -331,6 +336,7 @@ void hdelCommand(redisClient *c) {
if
((
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
if
((
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
if
(
hashTypeDelete
(
o
,
c
->
argv
[
2
]))
{
if
(
hashTypeDelete
(
o
,
c
->
argv
[
2
]))
{
if
(
hashTypeLength
(
o
)
==
0
)
dbDelete
(
c
->
db
,
c
->
argv
[
1
]);
if
(
hashTypeLength
(
o
)
==
0
)
dbDelete
(
c
->
db
,
c
->
argv
[
1
]);
addReply
(
c
,
shared
.
cone
);
addReply
(
c
,
shared
.
cone
);
...
@@ -395,5 +401,6 @@ void hexistsCommand(redisClient *c) {
...
@@ -395,5 +401,6 @@ void hexistsCommand(redisClient *c) {
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
addReply
(
c
,
hashTypeExists
(
o
,
c
->
argv
[
2
])
?
shared
.
cone
:
shared
.
czero
);
addReply
(
c
,
hashTypeExists
(
o
,
c
->
argv
[
2
])
?
shared
.
cone
:
shared
.
czero
);
}
}
src/t_list.c
View file @
75b41de8
...
@@ -260,6 +260,7 @@ void listTypeConvert(robj *subject, int enc) {
...
@@ -260,6 +260,7 @@ void listTypeConvert(robj *subject, int enc) {
void
pushGenericCommand
(
redisClient
*
c
,
int
where
)
{
void
pushGenericCommand
(
redisClient
*
c
,
int
where
)
{
robj
*
lobj
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
robj
*
lobj
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
if
(
lobj
==
NULL
)
{
if
(
lobj
==
NULL
)
{
if
(
handleClientsWaitingListPush
(
c
,
c
->
argv
[
1
],
c
->
argv
[
2
]))
{
if
(
handleClientsWaitingListPush
(
c
,
c
->
argv
[
1
],
c
->
argv
[
2
]))
{
addReply
(
c
,
shared
.
cone
);
addReply
(
c
,
shared
.
cone
);
...
@@ -346,14 +347,17 @@ void pushxGenericCommand(redisClient *c, robj *refval, robj *val, int where) {
...
@@ -346,14 +347,17 @@ void pushxGenericCommand(redisClient *c, robj *refval, robj *val, int where) {
}
}
void
lpushxCommand
(
redisClient
*
c
)
{
void
lpushxCommand
(
redisClient
*
c
)
{
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
pushxGenericCommand
(
c
,
NULL
,
c
->
argv
[
2
],
REDIS_HEAD
);
pushxGenericCommand
(
c
,
NULL
,
c
->
argv
[
2
],
REDIS_HEAD
);
}
}
void
rpushxCommand
(
redisClient
*
c
)
{
void
rpushxCommand
(
redisClient
*
c
)
{
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
pushxGenericCommand
(
c
,
NULL
,
c
->
argv
[
2
],
REDIS_TAIL
);
pushxGenericCommand
(
c
,
NULL
,
c
->
argv
[
2
],
REDIS_TAIL
);
}
}
void
linsertCommand
(
redisClient
*
c
)
{
void
linsertCommand
(
redisClient
*
c
)
{
c
->
argv
[
4
]
=
tryObjectEncoding
(
c
->
argv
[
4
]);
if
(
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"after"
)
==
0
)
{
if
(
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"after"
)
==
0
)
{
pushxGenericCommand
(
c
,
c
->
argv
[
3
],
c
->
argv
[
4
],
REDIS_TAIL
);
pushxGenericCommand
(
c
,
c
->
argv
[
3
],
c
->
argv
[
4
],
REDIS_TAIL
);
}
else
if
(
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"before"
)
==
0
)
{
}
else
if
(
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"before"
)
==
0
)
{
...
@@ -409,7 +413,7 @@ void lsetCommand(redisClient *c) {
...
@@ -409,7 +413,7 @@ void lsetCommand(redisClient *c) {
robj
*
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nokeyerr
);
robj
*
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nokeyerr
);
if
(
o
==
NULL
||
checkType
(
c
,
o
,
REDIS_LIST
))
return
;
if
(
o
==
NULL
||
checkType
(
c
,
o
,
REDIS_LIST
))
return
;
int
index
=
atoi
(
c
->
argv
[
2
]
->
ptr
);
int
index
=
atoi
(
c
->
argv
[
2
]
->
ptr
);
robj
*
value
=
c
->
argv
[
3
];
robj
*
value
=
(
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]))
;
listTypeTryConversion
(
o
,
value
);
listTypeTryConversion
(
o
,
value
);
if
(
o
->
encoding
==
REDIS_ENCODING_ZIPLIST
)
{
if
(
o
->
encoding
==
REDIS_ENCODING_ZIPLIST
)
{
...
@@ -559,7 +563,8 @@ void ltrimCommand(redisClient *c) {
...
@@ -559,7 +563,8 @@ void ltrimCommand(redisClient *c) {
}
}
void
lremCommand
(
redisClient
*
c
)
{
void
lremCommand
(
redisClient
*
c
)
{
robj
*
subject
,
*
obj
=
c
->
argv
[
3
];
robj
*
subject
,
*
obj
;
obj
=
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
int
toremove
=
atoi
(
c
->
argv
[
2
]
->
ptr
);
int
toremove
=
atoi
(
c
->
argv
[
2
]
->
ptr
);
int
removed
=
0
;
int
removed
=
0
;
listTypeEntry
entry
;
listTypeEntry
entry
;
...
...
src/t_set.c
View file @
75b41de8
...
@@ -178,6 +178,7 @@ void saddCommand(redisClient *c) {
...
@@ -178,6 +178,7 @@ void saddCommand(redisClient *c) {
robj
*
set
;
robj
*
set
;
set
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
set
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
if
(
set
==
NULL
)
{
if
(
set
==
NULL
)
{
set
=
setTypeCreate
(
c
->
argv
[
2
]);
set
=
setTypeCreate
(
c
->
argv
[
2
]);
dbAdd
(
c
->
db
,
c
->
argv
[
1
],
set
);
dbAdd
(
c
->
db
,
c
->
argv
[
1
],
set
);
...
@@ -202,6 +203,7 @@ void sremCommand(redisClient *c) {
...
@@ -202,6 +203,7 @@ void sremCommand(redisClient *c) {
if
((
set
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
if
((
set
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
set
,
REDIS_SET
))
return
;
checkType
(
c
,
set
,
REDIS_SET
))
return
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
if
(
setTypeRemove
(
set
,
c
->
argv
[
2
]))
{
if
(
setTypeRemove
(
set
,
c
->
argv
[
2
]))
{
if
(
setTypeSize
(
set
)
==
0
)
dbDelete
(
c
->
db
,
c
->
argv
[
1
]);
if
(
setTypeSize
(
set
)
==
0
)
dbDelete
(
c
->
db
,
c
->
argv
[
1
]);
touchWatchedKey
(
c
->
db
,
c
->
argv
[
1
]);
touchWatchedKey
(
c
->
db
,
c
->
argv
[
1
]);
...
@@ -216,7 +218,7 @@ void smoveCommand(redisClient *c) {
...
@@ -216,7 +218,7 @@ void smoveCommand(redisClient *c) {
robj
*
srcset
,
*
dstset
,
*
ele
;
robj
*
srcset
,
*
dstset
,
*
ele
;
srcset
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
srcset
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
dstset
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
2
]);
dstset
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
2
]);
ele
=
c
->
argv
[
3
];
ele
=
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
])
;
/* If the source key does not exist return 0 */
/* If the source key does not exist return 0 */
if
(
srcset
==
NULL
)
{
if
(
srcset
==
NULL
)
{
...
@@ -264,6 +266,7 @@ void sismemberCommand(redisClient *c) {
...
@@ -264,6 +266,7 @@ void sismemberCommand(redisClient *c) {
if
((
set
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
if
((
set
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
set
,
REDIS_SET
))
return
;
checkType
(
c
,
set
,
REDIS_SET
))
return
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
if
(
setTypeIsMember
(
set
,
c
->
argv
[
2
]))
if
(
setTypeIsMember
(
set
,
c
->
argv
[
2
]))
addReply
(
c
,
shared
.
cone
);
addReply
(
c
,
shared
.
cone
);
else
else
...
...
src/t_string.c
View file @
75b41de8
...
@@ -37,14 +37,17 @@ void setGenericCommand(redisClient *c, int nx, robj *key, robj *val, robj *expir
...
@@ -37,14 +37,17 @@ void setGenericCommand(redisClient *c, int nx, robj *key, robj *val, robj *expir
}
}
void
setCommand
(
redisClient
*
c
)
{
void
setCommand
(
redisClient
*
c
)
{
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
setGenericCommand
(
c
,
0
,
c
->
argv
[
1
],
c
->
argv
[
2
],
NULL
);
setGenericCommand
(
c
,
0
,
c
->
argv
[
1
],
c
->
argv
[
2
],
NULL
);
}
}
void
setnxCommand
(
redisClient
*
c
)
{
void
setnxCommand
(
redisClient
*
c
)
{
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
setGenericCommand
(
c
,
1
,
c
->
argv
[
1
],
c
->
argv
[
2
],
NULL
);
setGenericCommand
(
c
,
1
,
c
->
argv
[
1
],
c
->
argv
[
2
],
NULL
);
}
}
void
setexCommand
(
redisClient
*
c
)
{
void
setexCommand
(
redisClient
*
c
)
{
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
setGenericCommand
(
c
,
0
,
c
->
argv
[
1
],
c
->
argv
[
3
],
c
->
argv
[
2
]);
setGenericCommand
(
c
,
0
,
c
->
argv
[
1
],
c
->
argv
[
3
],
c
->
argv
[
2
]);
}
}
...
@@ -69,6 +72,7 @@ void getCommand(redisClient *c) {
...
@@ -69,6 +72,7 @@ void getCommand(redisClient *c) {
void
getsetCommand
(
redisClient
*
c
)
{
void
getsetCommand
(
redisClient
*
c
)
{
if
(
getGenericCommand
(
c
)
==
REDIS_ERR
)
return
;
if
(
getGenericCommand
(
c
)
==
REDIS_ERR
)
return
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
dbReplace
(
c
->
db
,
c
->
argv
[
1
],
c
->
argv
[
2
]);
dbReplace
(
c
->
db
,
c
->
argv
[
1
],
c
->
argv
[
2
]);
incrRefCount
(
c
->
argv
[
2
]);
incrRefCount
(
c
->
argv
[
2
]);
touchWatchedKey
(
c
->
db
,
c
->
argv
[
1
]);
touchWatchedKey
(
c
->
db
,
c
->
argv
[
1
]);
...
@@ -180,6 +184,7 @@ void appendCommand(redisClient *c) {
...
@@ -180,6 +184,7 @@ void appendCommand(redisClient *c) {
robj
*
o
;
robj
*
o
;
o
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
o
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
if
(
o
==
NULL
)
{
if
(
o
==
NULL
)
{
/* Create the key */
/* Create the key */
retval
=
dbAdd
(
c
->
db
,
c
->
argv
[
1
],
c
->
argv
[
2
]);
retval
=
dbAdd
(
c
->
db
,
c
->
argv
[
1
],
c
->
argv
[
2
]);
...
...
src/t_zset.c
View file @
75b41de8
...
@@ -392,12 +392,14 @@ void zaddGenericCommand(redisClient *c, robj *key, robj *ele, double score, int
...
@@ -392,12 +392,14 @@ void zaddGenericCommand(redisClient *c, robj *key, robj *ele, double score, int
void
zaddCommand
(
redisClient
*
c
)
{
void
zaddCommand
(
redisClient
*
c
)
{
double
scoreval
;
double
scoreval
;
if
(
getDoubleFromObjectOrReply
(
c
,
c
->
argv
[
2
],
&
scoreval
,
NULL
)
!=
REDIS_OK
)
return
;
if
(
getDoubleFromObjectOrReply
(
c
,
c
->
argv
[
2
],
&
scoreval
,
NULL
)
!=
REDIS_OK
)
return
;
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
zaddGenericCommand
(
c
,
c
->
argv
[
1
],
c
->
argv
[
3
],
scoreval
,
0
);
zaddGenericCommand
(
c
,
c
->
argv
[
1
],
c
->
argv
[
3
],
scoreval
,
0
);
}
}
void
zincrbyCommand
(
redisClient
*
c
)
{
void
zincrbyCommand
(
redisClient
*
c
)
{
double
scoreval
;
double
scoreval
;
if
(
getDoubleFromObjectOrReply
(
c
,
c
->
argv
[
2
],
&
scoreval
,
NULL
)
!=
REDIS_OK
)
return
;
if
(
getDoubleFromObjectOrReply
(
c
,
c
->
argv
[
2
],
&
scoreval
,
NULL
)
!=
REDIS_OK
)
return
;
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
zaddGenericCommand
(
c
,
c
->
argv
[
1
],
c
->
argv
[
3
],
scoreval
,
1
);
zaddGenericCommand
(
c
,
c
->
argv
[
1
],
c
->
argv
[
3
],
scoreval
,
1
);
}
}
...
@@ -412,6 +414,7 @@ void zremCommand(redisClient *c) {
...
@@ -412,6 +414,7 @@ void zremCommand(redisClient *c) {
checkType
(
c
,
zsetobj
,
REDIS_ZSET
))
return
;
checkType
(
c
,
zsetobj
,
REDIS_ZSET
))
return
;
zs
=
zsetobj
->
ptr
;
zs
=
zsetobj
->
ptr
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
de
=
dictFind
(
zs
->
dict
,
c
->
argv
[
2
]);
de
=
dictFind
(
zs
->
dict
,
c
->
argv
[
2
]);
if
(
de
==
NULL
)
{
if
(
de
==
NULL
)
{
addReply
(
c
,
shared
.
czero
);
addReply
(
c
,
shared
.
czero
);
...
@@ -921,6 +924,7 @@ void zscoreCommand(redisClient *c) {
...
@@ -921,6 +924,7 @@ void zscoreCommand(redisClient *c) {
checkType
(
c
,
o
,
REDIS_ZSET
))
return
;
checkType
(
c
,
o
,
REDIS_ZSET
))
return
;
zs
=
o
->
ptr
;
zs
=
o
->
ptr
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
de
=
dictFind
(
zs
->
dict
,
c
->
argv
[
2
]);
de
=
dictFind
(
zs
->
dict
,
c
->
argv
[
2
]);
if
(
!
de
)
{
if
(
!
de
)
{
addReply
(
c
,
shared
.
nullbulk
);
addReply
(
c
,
shared
.
nullbulk
);
...
@@ -944,6 +948,7 @@ void zrankGenericCommand(redisClient *c, int reverse) {
...
@@ -944,6 +948,7 @@ void zrankGenericCommand(redisClient *c, int reverse) {
zs
=
o
->
ptr
;
zs
=
o
->
ptr
;
zsl
=
zs
->
zsl
;
zsl
=
zs
->
zsl
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
de
=
dictFind
(
zs
->
dict
,
c
->
argv
[
2
]);
de
=
dictFind
(
zs
->
dict
,
c
->
argv
[
2
]);
if
(
!
de
)
{
if
(
!
de
)
{
addReply
(
c
,
shared
.
nullbulk
);
addReply
(
c
,
shared
.
nullbulk
);
...
...
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