2015-01-19 00:03:30 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
#include "acl_cpp/acl_cpp_define.hpp"
|
2015-01-23 17:23:04 +08:00
|
|
|
|
#include <vector>
|
|
|
|
|
#include <map>
|
2015-01-20 00:10:17 +08:00
|
|
|
|
#include "acl_cpp/redis/redis_command.hpp"
|
2015-01-19 00:03:30 +08:00
|
|
|
|
|
|
|
|
|
namespace acl
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class redis_client;
|
|
|
|
|
class redis_result;
|
|
|
|
|
class string;
|
|
|
|
|
|
2015-03-27 17:05:12 +08:00
|
|
|
|
class ACL_CPP_API redis_pubsub : virtual public redis_command
|
2015-01-19 00:03:30 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
2015-03-29 19:27:41 +08:00
|
|
|
|
/**
|
|
|
|
|
* see redis_command::redis_command()
|
|
|
|
|
*/
|
2016-01-17 13:35:12 +08:00
|
|
|
|
redis_pubsub(void);
|
2015-03-29 19:27:41 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* see redis_command::redis_command(redis_client*)
|
|
|
|
|
*/
|
2015-03-27 17:05:12 +08:00
|
|
|
|
redis_pubsub(redis_client* conn);
|
2015-03-29 19:27:41 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2015-04-02 22:19:57 +08:00
|
|
|
|
* see redis_command::redis_command(redis_client_cluster*<EFBFBD><EFBFBD> size_t)
|
2015-03-29 19:27:41 +08:00
|
|
|
|
*/
|
2016-01-17 13:35:12 +08:00
|
|
|
|
redis_pubsub(redis_client_cluster* cluster, size_t max_conns = 0);
|
2015-03-29 19:27:41 +08:00
|
|
|
|
|
2016-01-17 13:35:12 +08:00
|
|
|
|
virtual ~redis_pubsub(void);
|
2015-01-19 00:03:30 +08:00
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
/**
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD> channel
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* post a message to a channel
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @param channel {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the specified channel
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @param msg {const char*} <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the message to be sent
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @param len {size_t} <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the message's length
|
2015-01-19 00:03:30 +08:00
|
|
|
|
* @return {int} <EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the number of clients that received the message
|
2015-01-19 00:03:30 +08:00
|
|
|
|
* -1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* error happened
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* 0<EFBFBD><EFBFBD>û<EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* no client subscribe the channel
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* >0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the number of clients that received the message
|
2015-01-19 00:03:30 +08:00
|
|
|
|
*/
|
|
|
|
|
int publish(const char* channel, const char* msg, size_t len);
|
2015-01-23 17:23:04 +08:00
|
|
|
|
|
2015-01-29 00:38:29 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD>ܷ<EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>
|
|
|
|
|
* subscribe<EFBFBD><EFBFBD>unsubscribe<EFBFBD><EFBFBD>psubscribe<EFBFBD><EFBFBD>punsubscribe<EFBFBD><EFBFBD>get_message<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD>
|
|
|
|
|
* ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ű<EFBFBD><EFBFBD>Ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* subscribe one or more channel(s). Once the client enters the
|
|
|
|
|
* subscribed state it is not supposed to issue any other commands,
|
|
|
|
|
* except for additional SUBSCRIBE, PSUBSCRIBE, UNSUBSCRIBE
|
|
|
|
|
* and PUNSUBSCRIBE commands
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @param first_channel {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD>ĵ<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> NULL
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the first non-NULL channel in the channel list, and the last
|
|
|
|
|
* parameter must be NULL indicating the end of the channel list
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ǰ<EFBFBD>Ѿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the number of channels subscribed by the current client
|
2015-01-29 00:38:29 +08:00
|
|
|
|
*/
|
2015-01-19 00:03:30 +08:00
|
|
|
|
int subscribe(const char* first_channel, ...);
|
2015-01-23 17:23:04 +08:00
|
|
|
|
int subscribe(const std::vector<const char*>& channels);
|
2015-01-19 00:03:30 +08:00
|
|
|
|
int subscribe(const std::vector<string>& channels);
|
2015-01-23 17:23:04 +08:00
|
|
|
|
|
2015-01-29 00:38:29 +08:00
|
|
|
|
/**
|
|
|
|
|
* ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* stop listening for messages posted to the given channels
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @param first_channel {const char*} <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD>ĵ<EFBFBD>һ<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the fist channel in channel list, and the last parameter must be
|
|
|
|
|
* NULL indicating the end of the channel list
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the rest channels listened by the current client
|
2015-01-29 00:38:29 +08:00
|
|
|
|
*/
|
2015-01-19 00:03:30 +08:00
|
|
|
|
int unsubscribe(const char* first_channel, ...);
|
2015-01-23 17:23:04 +08:00
|
|
|
|
int unsubscribe(const std::vector<const char*>& channels);
|
2015-01-19 00:03:30 +08:00
|
|
|
|
int unsubscribe(const std::vector<string>& channels);
|
2015-01-23 17:23:04 +08:00
|
|
|
|
|
2015-01-29 00:38:29 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD> * <EFBFBD><EFBFBD>Ϊƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* ֻ<EFBFBD>ܷ<EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>subscribe<EFBFBD><EFBFBD>unsubscribe<EFBFBD><EFBFBD>psubscribe<EFBFBD><EFBFBD>punsubscribe<EFBFBD><EFBFBD>
|
|
|
|
|
* get_message<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ű<EFBFBD><EFBFBD>Ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* listen for messages published to channels matching the give patterns
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @param first_pattern {const char*} <EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the first pattern in pattern list, the last parameter must be NULL
|
|
|
|
|
* int the variable args
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ǰ<EFBFBD>Ѿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the number of channels listened by the current client
|
2015-01-29 00:38:29 +08:00
|
|
|
|
*/
|
2015-01-23 17:23:04 +08:00
|
|
|
|
int psubscribe(const char* first_pattern, ...);
|
|
|
|
|
int psubscribe(const std::vector<const char*>& patterns);
|
|
|
|
|
int psubscribe(const std::vector<string>& patterns);
|
|
|
|
|
|
2015-01-29 00:38:29 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽƥ<EFBFBD>䴮ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* stop listening for messaged posted to channels matching
|
|
|
|
|
* the given patterns
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @param first_pattern {const char*} <EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the first parttern in a variable args ending with NULL
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the rest number of channels be listened by the client
|
2015-01-29 00:38:29 +08:00
|
|
|
|
*/
|
2015-01-23 17:23:04 +08:00
|
|
|
|
int punsubscribe(const char* first_pattern, ...);
|
|
|
|
|
int punsubscribe(const std::vector<const char*>& patterns);
|
|
|
|
|
int punsubscribe(const std::vector<string>& patterns);
|
|
|
|
|
|
2015-01-29 00:38:29 +08:00
|
|
|
|
/**
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* <EFBFBD>ڶ<EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>л<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD> subscribe <EFBFBD><EFBFBD> psubscribe <EFBFBD><EFBFBD><EFBFBD>ſɵ<EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
* get messages posted to channels after SUBSCRIBE or PSUBSCRIBE
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @param channel {string&} <EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* buffer for storing the channel associate with the msg
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @param msg {string&} <EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* store the message posted to the channel
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @return {bool} <EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> false <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* true on success, false on error
|
2015-01-29 00:38:29 +08:00
|
|
|
|
*/
|
2015-01-19 00:03:30 +08:00
|
|
|
|
bool get_message(string& channel, string& msg);
|
|
|
|
|
|
2015-01-29 00:38:29 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>г<EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>Ļ<EFBFBD>ԾƵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԾƵ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD>ͻ<EFBFBD><EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* Lists the currently active channels.
|
2015-01-30 22:58:13 +08:00
|
|
|
|
* @param channels {std::vector<string>*} <EFBFBD>ǿ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* store the active channels
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @param first_pattern {const char*} <EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ƥ<EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ NULL<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ȡָ<EFBFBD><EFBFBD><EFBFBD>еĻ<EFBFBD>ԾƵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><EFBFBD>ζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ NULL
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the first pattern in a variable args ending with NULL arg, and
|
|
|
|
|
* the first arg can be NULL.
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD>ػ<EFBFBD>ԾƵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -1 <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the number of active channels. -1 if error
|
2015-01-29 00:38:29 +08:00
|
|
|
|
*
|
2015-01-30 22:58:13 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* 1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> get_value <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>±<EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* 2<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> get_child <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>±<EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD>(redis_result<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>
|
|
|
|
|
* redis_result::argv_to_string <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* 3<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> get_result <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> redis_result<EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>
|
|
|
|
|
* redis_result::get_child <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>Ԫ<EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ 2 <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD>Ԫ<EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* 4<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> get_children <EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD> redis_result <EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD> argv_to_string <EFBFBD><EFBFBD>ÿһ<EFBFBD><EFBFBD>Ԫ<EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* 5<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿյĴ洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ
|
|
|
|
|
*
|
2015-01-29 00:38:29 +08:00
|
|
|
|
*/
|
2015-01-30 22:58:13 +08:00
|
|
|
|
int pubsub_channels(std::vector<string>* channels,
|
2015-01-23 17:23:04 +08:00
|
|
|
|
const char* first_pattern, ...);
|
|
|
|
|
int pubsub_channels(const std::vector<const char*>& patterns,
|
2015-01-30 22:58:13 +08:00
|
|
|
|
std::vector<string>* channels);
|
2015-01-23 17:23:04 +08:00
|
|
|
|
int pubsub_channels(const std::vector<string>& patterns,
|
2015-01-30 22:58:13 +08:00
|
|
|
|
std::vector<string>* channels);
|
2015-01-23 17:23:04 +08:00
|
|
|
|
|
2015-01-29 00:38:29 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>Ŀͻ<EFBFBD><EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* Returns the number of subscribers (not counting clients
|
|
|
|
|
* subscribed to patterns) for the specified channels.
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @param out {std::map<string, int>&} <EFBFBD>洢<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> out->first <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>out->second <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* store the results
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @param first_pattern {const char*} <EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ƥ<EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ NULL<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ȡָ<EFBFBD><EFBFBD><EFBFBD>еĻ<EFBFBD>ԾƵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><EFBFBD>ζ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ NULL
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the first pattern in a variable args ending with NULL arg, and
|
|
|
|
|
* the first arg can be NULL.
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @return {int} Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-1 <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2015-01-23 17:23:04 +08:00
|
|
|
|
int pubsub_numsub(std::map<string, int>& out,
|
|
|
|
|
const char* first_channel, ...);
|
|
|
|
|
int pubsub_numsub(const std::vector<const char*>& channels,
|
|
|
|
|
std::map<string, int>& out);
|
|
|
|
|
int pubsub_numsub(const std::vector<string>& channels,
|
|
|
|
|
std::map<string, int>& out);
|
|
|
|
|
|
2015-01-29 00:38:29 +08:00
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>صIJ<EFBFBD><EFBFBD>Ƕ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>Ŀͻ<EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>ǿͻ<EFBFBD><EFBFBD>˶<EFBFBD><EFBFBD>ĵ<EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܺ<EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* Returns the number of subscriptions to patterns.
|
2015-01-29 00:38:29 +08:00
|
|
|
|
* @return {int} <EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD>ܺͣ<EFBFBD>-1 <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-04-12 21:37:17 +08:00
|
|
|
|
* the number of patterns all the clients are subscribed to,
|
|
|
|
|
* -1 if error.
|
2015-01-29 00:38:29 +08:00
|
|
|
|
*/
|
2015-01-23 17:23:04 +08:00
|
|
|
|
int pubsub_numpat();
|
|
|
|
|
|
2015-01-19 00:03:30 +08:00
|
|
|
|
private:
|
2015-01-23 17:23:04 +08:00
|
|
|
|
int subop(const char* cmd, const std::vector<const char*>& channels);
|
2015-01-20 00:10:17 +08:00
|
|
|
|
int subop(const char* cmd, const std::vector<string>& channels);
|
2015-01-19 00:03:30 +08:00
|
|
|
|
int check_channel(const redis_result* obj, const char* cmd,
|
|
|
|
|
const string& channel);
|
2015-01-26 19:58:02 +08:00
|
|
|
|
int pubsub_numsub(std::map<string, int>& out);
|
2015-01-19 00:03:30 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|