mirror of
https://github.com/fluencelabs/redis
synced 2025-03-30 22:31:03 +00:00
Variadic PING with support for Pub/Sub.
PING can now be called with an additional arugment, behaving exactly like the ECHO command. PING can now also be called in Pub/Sub mode (with one more more subscriptions to channels / patterns) in order to trigger the delivery of an asynchronous pong message with the optional payload. This fixes issue #420.
This commit is contained in:
parent
59cf0824d9
commit
27839e5ecb
22
src/redis.c
22
src/redis.c
@ -224,7 +224,7 @@ struct redisCommand redisCommandTable[] = {
|
|||||||
{"scan",scanCommand,-2,"rR",0,NULL,0,0,0,0,0},
|
{"scan",scanCommand,-2,"rR",0,NULL,0,0,0,0,0},
|
||||||
{"dbsize",dbsizeCommand,1,"rF",0,NULL,0,0,0,0,0},
|
{"dbsize",dbsizeCommand,1,"rF",0,NULL,0,0,0,0,0},
|
||||||
{"auth",authCommand,2,"rsltF",0,NULL,0,0,0,0,0},
|
{"auth",authCommand,2,"rsltF",0,NULL,0,0,0,0,0},
|
||||||
{"ping",pingCommand,1,"rtF",0,NULL,0,0,0,0,0},
|
{"ping",pingCommand,-1,"rtF",0,NULL,0,0,0,0,0},
|
||||||
{"echo",echoCommand,2,"rF",0,NULL,0,0,0,0,0},
|
{"echo",echoCommand,2,"rF",0,NULL,0,0,0,0,0},
|
||||||
{"save",saveCommand,1,"ars",0,NULL,0,0,0,0,0},
|
{"save",saveCommand,1,"ars",0,NULL,0,0,0,0,0},
|
||||||
{"bgsave",bgsaveCommand,1,"ar",0,NULL,0,0,0,0,0},
|
{"bgsave",bgsaveCommand,1,"ar",0,NULL,0,0,0,0,0},
|
||||||
@ -2398,8 +2398,28 @@ void authCommand(redisClient *c) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The PING command. It works in a different way if the client is in
|
||||||
|
* in Pub/Sub mode. */
|
||||||
void pingCommand(redisClient *c) {
|
void pingCommand(redisClient *c) {
|
||||||
|
/* The command takes zero or one arguments. */
|
||||||
|
if (c->argc > 2) {
|
||||||
|
addReply(c,shared.syntaxerr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c->flags & REDIS_PUBSUB) {
|
||||||
|
addReply(c,shared.mbulkhdr[2]);
|
||||||
|
addReplyBulkCBuffer(c,"pong",4);
|
||||||
|
if (c->argc == 1)
|
||||||
|
addReplyBulkCBuffer(c,"",0);
|
||||||
|
else
|
||||||
|
addReplyBulk(c,c->argv[1]);
|
||||||
|
} else {
|
||||||
|
if (c->argc == 1)
|
||||||
addReply(c,shared.pong);
|
addReply(c,shared.pong);
|
||||||
|
else
|
||||||
|
addReplyBulk(c,c->argv[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void echoCommand(redisClient *c) {
|
void echoCommand(redisClient *c) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user