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
0537e7bf
"doc/KeysCommand.html" did not exist on "81d456450ac42b7cf78367ae3a89af1a543c9ff1"
Commit
0537e7bf
authored
Sep 02, 2010
by
Pieter Noordhuis
Browse files
Use specialized function to add multi bulk reply length
parent
57b07380
Changes
9
Show whitespace changes
Inline
Side-by-side
src/multi.c
View file @
0537e7bf
...
@@ -107,7 +107,7 @@ void execCommand(redisClient *c) {
...
@@ -107,7 +107,7 @@ void execCommand(redisClient *c) {
unwatchAllKeys
(
c
);
/* Unwatch ASAP otherwise we'll waste CPU cycles */
unwatchAllKeys
(
c
);
/* Unwatch ASAP otherwise we'll waste CPU cycles */
orig_argv
=
c
->
argv
;
orig_argv
=
c
->
argv
;
orig_argc
=
c
->
argc
;
orig_argc
=
c
->
argc
;
addReply
Sds
(
c
,
sdscatprintf
(
sdsempty
(),
"*%d
\r\n
"
,
c
->
mstate
.
count
)
)
;
addReply
MultiBulkLen
(
c
,
c
->
mstate
.
count
);
for
(
j
=
0
;
j
<
c
->
mstate
.
count
;
j
++
)
{
for
(
j
=
0
;
j
<
c
->
mstate
.
count
;
j
++
)
{
c
->
argc
=
c
->
mstate
.
commands
[
j
].
argc
;
c
->
argc
=
c
->
mstate
.
commands
[
j
].
argc
;
c
->
argv
=
c
->
mstate
.
commands
[
j
].
argv
;
c
->
argv
=
c
->
mstate
.
commands
[
j
].
argv
;
...
...
src/networking.c
View file @
0537e7bf
...
@@ -200,6 +200,10 @@ void addReplyUlong(redisClient *c, unsigned long ul) {
...
@@ -200,6 +200,10 @@ void addReplyUlong(redisClient *c, unsigned long ul) {
_addReplyLongLong
(
c
,(
long
long
)
ul
,
':'
);
_addReplyLongLong
(
c
,(
long
long
)
ul
,
':'
);
}
}
void
addReplyMultiBulkLen
(
redisClient
*
c
,
long
length
)
{
_addReplyLongLong
(
c
,
length
,
'*'
);
}
void
addReplyBulkLen
(
redisClient
*
c
,
robj
*
obj
)
{
void
addReplyBulkLen
(
redisClient
*
c
,
robj
*
obj
)
{
size_t
len
;
size_t
len
;
...
...
src/redis.h
View file @
0537e7bf
...
@@ -617,6 +617,7 @@ void addReplySds(redisClient *c, sds s);
...
@@ -617,6 +617,7 @@ void addReplySds(redisClient *c, sds s);
void
addReplyDouble
(
redisClient
*
c
,
double
d
);
void
addReplyDouble
(
redisClient
*
c
,
double
d
);
void
addReplyLongLong
(
redisClient
*
c
,
long
long
ll
);
void
addReplyLongLong
(
redisClient
*
c
,
long
long
ll
);
void
addReplyUlong
(
redisClient
*
c
,
unsigned
long
ul
);
void
addReplyUlong
(
redisClient
*
c
,
unsigned
long
ul
);
void
addReplyMultiBulkLen
(
redisClient
*
c
,
long
length
);
void
*
dupClientReplyValue
(
void
*
o
);
void
*
dupClientReplyValue
(
void
*
o
);
/* List data type */
/* List data type */
...
...
src/sort.c
View file @
0537e7bf
...
@@ -307,7 +307,7 @@ void sortCommand(redisClient *c) {
...
@@ -307,7 +307,7 @@ void sortCommand(redisClient *c) {
outputlen
=
getop
?
getop
*
(
end
-
start
+
1
)
:
end
-
start
+
1
;
outputlen
=
getop
?
getop
*
(
end
-
start
+
1
)
:
end
-
start
+
1
;
if
(
storekey
==
NULL
)
{
if
(
storekey
==
NULL
)
{
/* STORE option not specified, sent the sorting result to client */
/* STORE option not specified, sent the sorting result to client */
addReply
Sds
(
c
,
sdscatprintf
(
sdsempty
(),
"*%d
\r\n
"
,
outputlen
)
)
;
addReply
MultiBulkLen
(
c
,
outputlen
);
for
(
j
=
start
;
j
<=
end
;
j
++
)
{
for
(
j
=
start
;
j
<=
end
;
j
++
)
{
listNode
*
ln
;
listNode
*
ln
;
listIter
li
;
listIter
li
;
...
...
src/t_hash.c
View file @
0537e7bf
...
@@ -315,7 +315,7 @@ void hmgetCommand(redisClient *c) {
...
@@ -315,7 +315,7 @@ void hmgetCommand(redisClient *c) {
/* Note the check for o != NULL happens inside the loop. This is
/* Note the check for o != NULL happens inside the loop. This is
* 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. */
addReply
Sds
(
c
,
sdscatprintf
(
sdsempty
(),
"*%d
\r\n
"
,
c
->
argc
-
2
)
)
;
addReply
MultiBulkLen
(
c
,
c
->
argc
-
2
);
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
);
...
...
src/t_list.c
View file @
0537e7bf
...
@@ -494,7 +494,7 @@ void lrangeCommand(redisClient *c) {
...
@@ -494,7 +494,7 @@ void lrangeCommand(redisClient *c) {
rangelen
=
(
end
-
start
)
+
1
;
rangelen
=
(
end
-
start
)
+
1
;
/* Return the result in form of a multi-bulk reply */
/* Return the result in form of a multi-bulk reply */
addReply
Sds
(
c
,
sdscatprintf
(
sdsempty
(),
"*%d
\r\n
"
,
rangelen
)
)
;
addReply
MultiBulkLen
(
c
,
rangelen
);
listTypeIterator
*
li
=
listTypeInitIterator
(
o
,
start
,
REDIS_TAIL
);
listTypeIterator
*
li
=
listTypeInitIterator
(
o
,
start
,
REDIS_TAIL
);
for
(
j
=
0
;
j
<
rangelen
;
j
++
)
{
for
(
j
=
0
;
j
<
rangelen
;
j
++
)
{
redisAssert
(
listTypeNext
(
li
,
&
entry
));
redisAssert
(
listTypeNext
(
li
,
&
entry
));
...
@@ -772,7 +772,7 @@ int handleClientsWaitingListPush(redisClient *c, robj *key, robj *ele) {
...
@@ -772,7 +772,7 @@ int handleClientsWaitingListPush(redisClient *c, robj *key, robj *ele) {
redisAssert
(
ln
!=
NULL
);
redisAssert
(
ln
!=
NULL
);
receiver
=
ln
->
value
;
receiver
=
ln
->
value
;
addReply
Sds
(
receiver
,
sdsnew
(
"*2
\r\n
"
)
);
addReply
MultiBulkLen
(
receiver
,
2
);
addReplyBulk
(
receiver
,
key
);
addReplyBulk
(
receiver
,
key
);
addReplyBulk
(
receiver
,
ele
);
addReplyBulk
(
receiver
,
ele
);
unblockClientWaitingData
(
receiver
);
unblockClientWaitingData
(
receiver
);
...
@@ -811,7 +811,7 @@ void blockingPopGenericCommand(redisClient *c, int where) {
...
@@ -811,7 +811,7 @@ void blockingPopGenericCommand(redisClient *c, int where) {
* "real" command will add the last element (the value)
* "real" command will add the last element (the value)
* for us. If this souds like an hack to you it's just
* for us. If this souds like an hack to you it's just
* because it is... */
* because it is... */
addReply
Sds
(
c
,
sdsnew
(
"*2
\r\n
"
)
);
addReply
MultiBulkLen
(
c
,
2
);
addReplyBulk
(
c
,
argv
[
1
]);
addReplyBulk
(
c
,
argv
[
1
]);
popGenericCommand
(
c
,
where
);
popGenericCommand
(
c
,
where
);
...
...
src/t_set.c
View file @
0537e7bf
...
@@ -469,7 +469,7 @@ void sunionDiffGenericCommand(redisClient *c, robj **setkeys, int setnum, robj *
...
@@ -469,7 +469,7 @@ void sunionDiffGenericCommand(redisClient *c, robj **setkeys, int setnum, robj *
/* Output the content of the resulting set, if not in STORE mode */
/* Output the content of the resulting set, if not in STORE mode */
if
(
!
dstkey
)
{
if
(
!
dstkey
)
{
addReply
Sds
(
c
,
sdscatprintf
(
sdsempty
(),
"*%d
\r\n
"
,
cardinality
)
)
;
addReply
MultiBulkLen
(
c
,
cardinality
);
si
=
setTypeInitIterator
(
dstset
);
si
=
setTypeInitIterator
(
dstset
);
while
((
ele
=
setTypeNext
(
si
))
!=
NULL
)
{
while
((
ele
=
setTypeNext
(
si
))
!=
NULL
)
{
addReplyBulk
(
c
,
ele
);
addReplyBulk
(
c
,
ele
);
...
...
src/t_string.c
View file @
0537e7bf
...
@@ -79,7 +79,7 @@ void getsetCommand(redisClient *c) {
...
@@ -79,7 +79,7 @@ void getsetCommand(redisClient *c) {
void
mgetCommand
(
redisClient
*
c
)
{
void
mgetCommand
(
redisClient
*
c
)
{
int
j
;
int
j
;
addReply
Sds
(
c
,
sdscatprintf
(
sdsempty
(),
"*%d
\r\n
"
,
c
->
argc
-
1
)
)
;
addReply
MultiBulkLen
(
c
,
c
->
argc
-
1
);
for
(
j
=
1
;
j
<
c
->
argc
;
j
++
)
{
for
(
j
=
1
;
j
<
c
->
argc
;
j
++
)
{
robj
*
o
=
lookupKeyRead
(
c
->
db
,
c
->
argv
[
j
]);
robj
*
o
=
lookupKeyRead
(
c
->
db
,
c
->
argv
[
j
]);
if
(
o
==
NULL
)
{
if
(
o
==
NULL
)
{
...
...
src/t_zset.c
View file @
0537e7bf
...
@@ -782,8 +782,7 @@ void zrangeGenericCommand(redisClient *c, int reverse) {
...
@@ -782,8 +782,7 @@ void zrangeGenericCommand(redisClient *c, int reverse) {
}
}
/* Return the result in form of a multi-bulk reply */
/* Return the result in form of a multi-bulk reply */
addReplySds
(
c
,
sdscatprintf
(
sdsempty
(),
"*%d
\r\n
"
,
addReplyMultiBulkLen
(
c
,
withscores
?
(
rangelen
*
2
)
:
rangelen
);
withscores
?
(
rangelen
*
2
)
:
rangelen
));
for
(
j
=
0
;
j
<
rangelen
;
j
++
)
{
for
(
j
=
0
;
j
<
rangelen
;
j
++
)
{
ele
=
ln
->
obj
;
ele
=
ln
->
obj
;
addReplyBulk
(
c
,
ele
);
addReplyBulk
(
c
,
ele
);
...
...
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