acl/lib_acl_cpp/include/acl_cpp/redis/redis_pubsub.hpp

41 lines
1.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include "acl_cpp/acl_cpp_define.hpp"
#include "acl_cpp/redis/redis_command.hpp"
namespace acl
{
class redis_client;
class redis_result;
class string;
class ACL_CPP_API redis_pubsub : public redis_command
{
public:
redis_pubsub(redis_client* conn = NULL);
~redis_pubsub();
/////////////////////////////////////////////////////////////////////
/**
*
* @return {int} 成功发送至订阅该频道的订阅者数量
* -1表示出错
* 0没有订阅者
* > 0订阅该频道的订阅者数量
*/
int publish(const char* channel, const char* msg, size_t len);
int subscribe(const char* first_channel, ...);
int subscribe(const std::vector<string>& channels);
int unsubscribe(const char* first_channel, ...);
int unsubscribe(const std::vector<string>& channels);
bool get_message(string& channel, string& msg);
private:
int subop(const char* cmd, const std::vector<string>& channels);
int check_channel(const redis_result* obj, const char* cmd,
const string& channel);
};
} // namespace acl