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-01-20 00:10:17 +08:00
|
|
|
|
class ACL_CPP_API redis_pubsub : public redis_command
|
2015-01-19 00:03:30 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
redis_pubsub(redis_client* conn = NULL);
|
|
|
|
|
~redis_pubsub();
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @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>
|
|
|
|
|
* -1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* 0<EFBFBD><EFBFBD>û<EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* > 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
int publish(const char* channel, const char* msg, size_t len);
|
2015-01-23 17:23:04 +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-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
|
|
|
|
|
|
|
|
|
int psubscribe(const char* first_pattern, ...);
|
|
|
|
|
int psubscribe(const std::vector<const char*>& patterns);
|
|
|
|
|
int psubscribe(const std::vector<string>& patterns);
|
|
|
|
|
|
|
|
|
|
int punsubscribe(const char* first_pattern, ...);
|
|
|
|
|
int punsubscribe(const std::vector<const char*>& patterns);
|
|
|
|
|
int punsubscribe(const std::vector<string>& patterns);
|
|
|
|
|
|
2015-01-19 00:03:30 +08:00
|
|
|
|
bool get_message(string& channel, string& msg);
|
|
|
|
|
|
2015-01-23 17:23:04 +08:00
|
|
|
|
int pubsub_channels(std::vector<string>& channels,
|
|
|
|
|
const char* first_pattern, ...);
|
|
|
|
|
int pubsub_channels(const std::vector<const char*>& patterns,
|
|
|
|
|
std::vector<string>& channels);
|
|
|
|
|
int pubsub_channels(const std::vector<string>& patterns,
|
|
|
|
|
std::vector<string>& channels);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
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-23 17:23:04 +08:00
|
|
|
|
int pubsub_numsub(const string& req, std::map<string, int>& out);
|
2015-01-19 00:03:30 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|