Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
b70d3555
Commit
b70d3555
authored
Sep 02, 2010
by
Pieter Noordhuis
Browse files
Use existing reply functions where possible
parent
cd76bb65
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/db.c
View file @
b70d3555
...
@@ -245,13 +245,11 @@ void keysCommand(redisClient *c) {
...
@@ -245,13 +245,11 @@ void keysCommand(redisClient *c) {
}
}
void
dbsizeCommand
(
redisClient
*
c
)
{
void
dbsizeCommand
(
redisClient
*
c
)
{
addReplySds
(
c
,
addReplyLongLong
(
c
,
dictSize
(
c
->
db
->
dict
));
sdscatprintf
(
sdsempty
(),
":%lu
\r\n
"
,
dictSize
(
c
->
db
->
dict
)));
}
}
void
lastsaveCommand
(
redisClient
*
c
)
{
void
lastsaveCommand
(
redisClient
*
c
)
{
addReplySds
(
c
,
addReplyLongLong
(
c
,
server
.
lastsave
);
sdscatprintf
(
sdsempty
(),
":%lu
\r\n
"
,
server
.
lastsave
));
}
}
void
typeCommand
(
redisClient
*
c
)
{
void
typeCommand
(
redisClient
*
c
)
{
...
...
src/sort.c
View file @
b70d3555
...
@@ -369,7 +369,7 @@ void sortCommand(redisClient *c) {
...
@@ -369,7 +369,7 @@ void sortCommand(redisClient *c) {
* replaced. */
* replaced. */
server
.
dirty
+=
1
+
outputlen
;
server
.
dirty
+=
1
+
outputlen
;
touchWatchedKey
(
c
->
db
,
storekey
);
touchWatchedKey
(
c
->
db
,
storekey
);
addReply
Sds
(
c
,
sdscatprintf
(
sdsempty
(),
":%d
\r\n
"
,
outputlen
)
)
;
addReply
LongLong
(
c
,
outputlen
);
}
}
/* Cleanup */
/* Cleanup */
...
...
src/t_hash.c
View file @
b70d3555
...
@@ -346,7 +346,7 @@ void hlenCommand(redisClient *c) {
...
@@ -346,7 +346,7 @@ void hlenCommand(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
;
addReply
Ul
ong
(
c
,
hashTypeLength
(
o
));
addReply
LongL
ong
(
c
,
hashTypeLength
(
o
));
}
}
void
genericHgetallCommand
(
redisClient
*
c
,
int
flags
)
{
void
genericHgetallCommand
(
redisClient
*
c
,
int
flags
)
{
...
...
src/t_list.c
View file @
b70d3555
...
@@ -342,7 +342,7 @@ void pushxGenericCommand(redisClient *c, robj *refval, robj *val, int where) {
...
@@ -342,7 +342,7 @@ void pushxGenericCommand(redisClient *c, robj *refval, robj *val, int where) {
server
.
dirty
++
;
server
.
dirty
++
;
}
}
addReply
Ul
ong
(
c
,
listTypeLength
(
subject
));
addReply
LongL
ong
(
c
,
listTypeLength
(
subject
));
}
}
void
lpushxCommand
(
redisClient
*
c
)
{
void
lpushxCommand
(
redisClient
*
c
)
{
...
@@ -366,7 +366,7 @@ void linsertCommand(redisClient *c) {
...
@@ -366,7 +366,7 @@ void linsertCommand(redisClient *c) {
void
llenCommand
(
redisClient
*
c
)
{
void
llenCommand
(
redisClient
*
c
)
{
robj
*
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
);
robj
*
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
);
if
(
o
==
NULL
||
checkType
(
c
,
o
,
REDIS_LIST
))
return
;
if
(
o
==
NULL
||
checkType
(
c
,
o
,
REDIS_LIST
))
return
;
addReply
Ul
ong
(
c
,
listTypeLength
(
o
));
addReply
LongL
ong
(
c
,
listTypeLength
(
o
));
}
}
void
lindexCommand
(
redisClient
*
c
)
{
void
lindexCommand
(
redisClient
*
c
)
{
...
@@ -594,7 +594,7 @@ void lremCommand(redisClient *c) {
...
@@ -594,7 +594,7 @@ void lremCommand(redisClient *c) {
decrRefCount
(
obj
);
decrRefCount
(
obj
);
if
(
listTypeLength
(
subject
)
==
0
)
dbDelete
(
c
->
db
,
c
->
argv
[
1
]);
if
(
listTypeLength
(
subject
)
==
0
)
dbDelete
(
c
->
db
,
c
->
argv
[
1
]);
addReply
Sds
(
c
,
sdscatprintf
(
sdsempty
(),
":%d
\r\n
"
,
removed
)
)
;
addReply
LongLong
(
c
,
removed
);
if
(
removed
)
touchWatchedKey
(
c
->
db
,
c
->
argv
[
1
]);
if
(
removed
)
touchWatchedKey
(
c
->
db
,
c
->
argv
[
1
]);
}
}
...
...
src/t_set.c
View file @
b70d3555
...
@@ -276,7 +276,7 @@ void scardCommand(redisClient *c) {
...
@@ -276,7 +276,7 @@ void scardCommand(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_SET
))
return
;
checkType
(
c
,
o
,
REDIS_SET
))
return
;
addReply
Ul
ong
(
c
,
setTypeSize
(
o
));
addReply
LongL
ong
(
c
,
setTypeSize
(
o
));
}
}
void
spopCommand
(
redisClient
*
c
)
{
void
spopCommand
(
redisClient
*
c
)
{
...
...
src/t_string.c
View file @
b70d3555
...
@@ -211,7 +211,7 @@ void appendCommand(redisClient *c) {
...
@@ -211,7 +211,7 @@ void appendCommand(redisClient *c) {
}
}
touchWatchedKey
(
c
->
db
,
c
->
argv
[
1
]);
touchWatchedKey
(
c
->
db
,
c
->
argv
[
1
]);
server
.
dirty
++
;
server
.
dirty
++
;
addReply
Sds
(
c
,
sdscatprintf
(
sdsempty
(),
":%lu
\r\n
"
,(
unsigned
long
)
totlen
)
)
;
addReply
LongLong
(
c
,
totlen
);
}
}
void
substrCommand
(
redisClient
*
c
)
{
void
substrCommand
(
redisClient
*
c
)
{
...
...
src/t_zset.c
View file @
b70d3555
...
@@ -930,7 +930,7 @@ void zcardCommand(redisClient *c) {
...
@@ -930,7 +930,7 @@ void zcardCommand(redisClient *c) {
checkType
(
c
,
o
,
REDIS_ZSET
))
return
;
checkType
(
c
,
o
,
REDIS_ZSET
))
return
;
zs
=
o
->
ptr
;
zs
=
o
->
ptr
;
addReply
Ul
ong
(
c
,
zs
->
zsl
->
length
);
addReply
LongL
ong
(
c
,
zs
->
zsl
->
length
);
}
}
void
zscoreCommand
(
redisClient
*
c
)
{
void
zscoreCommand
(
redisClient
*
c
)
{
...
...
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