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
3e8c69a9
Commit
3e8c69a9
authored
Feb 10, 2020
by
antirez
Browse files
Tracking: always reply with an array of keys.
parent
a788c373
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/pubsub.c
View file @
3e8c69a9
...
@@ -35,7 +35,11 @@ int clientSubscriptionsCount(client *c);
...
@@ -35,7 +35,11 @@ int clientSubscriptionsCount(client *c);
* Pubsub client replies API
* Pubsub client replies API
*----------------------------------------------------------------------------*/
*----------------------------------------------------------------------------*/
/* Send a pubsub message of type "message" to the client. */
/* Send a pubsub message of type "message" to the client.
* Normally 'msg' is a Redis object containing the string to send as
* message. However if the caller sets 'msg' as NULL, it will be able
* to send a special message (for instance an Array type) by using the
* addReply*() API family. */
void
addReplyPubsubMessage
(
client
*
c
,
robj
*
channel
,
robj
*
msg
)
{
void
addReplyPubsubMessage
(
client
*
c
,
robj
*
channel
,
robj
*
msg
)
{
if
(
c
->
resp
==
2
)
if
(
c
->
resp
==
2
)
addReply
(
c
,
shared
.
mbulkhdr
[
3
]);
addReply
(
c
,
shared
.
mbulkhdr
[
3
]);
...
@@ -43,7 +47,7 @@ void addReplyPubsubMessage(client *c, robj *channel, robj *msg) {
...
@@ -43,7 +47,7 @@ void addReplyPubsubMessage(client *c, robj *channel, robj *msg) {
addReplyPushLen
(
c
,
3
);
addReplyPushLen
(
c
,
3
);
addReply
(
c
,
shared
.
messagebulk
);
addReply
(
c
,
shared
.
messagebulk
);
addReplyBulk
(
c
,
channel
);
addReplyBulk
(
c
,
channel
);
addReplyBulk
(
c
,
msg
);
if
(
msg
)
addReplyBulk
(
c
,
msg
);
}
}
/* Send a pubsub message of type "pmessage" to the client. The difference
/* Send a pubsub message of type "pmessage" to the client. The difference
...
...
src/tracking.c
View file @
3e8c69a9
...
@@ -132,13 +132,16 @@ void sendTrackingMessage(client *c, char *keyname, size_t keylen) {
...
@@ -132,13 +132,16 @@ void sendTrackingMessage(client *c, char *keyname, size_t keylen) {
if
(
c
->
resp
>
2
)
{
if
(
c
->
resp
>
2
)
{
addReplyPushLen
(
c
,
2
);
addReplyPushLen
(
c
,
2
);
addReplyBulkCBuffer
(
c
,
"invalidate"
,
10
);
addReplyBulkCBuffer
(
c
,
"invalidate"
,
10
);
addReplyArrayLen
(
c
,
1
);
addReplyBulkCBuffer
(
c
,
keyname
,
keylen
);
addReplyBulkCBuffer
(
c
,
keyname
,
keylen
);
}
else
if
(
using_redirection
&&
c
->
flags
&
CLIENT_PUBSUB
)
{
}
else
if
(
using_redirection
&&
c
->
flags
&
CLIENT_PUBSUB
)
{
/* We use a static object to speedup things, however we assume
/* We use a static object to speedup things, however we assume
* that addReplyPubsubMessage() will not take a reference. */
* that addReplyPubsubMessage() will not take a reference. */
robj
keyobj
;
robj
keyobj
;
initStaticStringObject
(
keyobj
,
keyname
);
initStaticStringObject
(
keyobj
,
keyname
);
addReplyPubsubMessage
(
c
,
TrackingChannelName
,
&
keyobj
);
addReplyPubsubMessage
(
c
,
TrackingChannelName
,
NULL
);
addReplyArrayLen
(
c
,
1
);
addReplyBulk
(
c
,
&
keyobj
);
serverAssert
(
keyobj
.
refcount
==
1
);
serverAssert
(
keyobj
.
refcount
==
1
);
}
}
}
}
...
...
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