acl  3.5.3.0
acl::redis_stream类 参考

#include <redis_stream.hpp>

+ 类 acl::redis_stream 继承关系图:
+ acl::redis_stream 的协作图:

Public 成员函数

 redis_stream (void)
 
 redis_stream (redis_client *conn)
 
 redis_stream (redis_client_cluster *cluster)
 
 redis_stream (redis_client_pipeline *pipeline)
 
ACL_CPP_DEPRECATED redis_stream (redis_client_cluster *cluster, size_t max_conns)
 
virtual ~redis_stream (void)
 
bool xadd (const char *key, const std::map< string, string > &fields, string &result, const char *id="*")
 
bool xadd (const char *key, const std::vector< string > &names, const std::vector< string > &values, string &result, const char *id="*")
 
bool xadd (const char *key, const std::vector< const char * > &names, const std::vector< const char * > &values, string &result, const char *id="*")
 
bool xadd (const char *key, const char *names[], const size_t names_len[], const char *values[], const size_t values_len[], size_t argc, string &result, const char *id="*")
 
bool xadd_with_maxlen (const char *key, size_t maxlen, const std::map< string, string > &fields, string &result, const char *id="*")
 
int xlen (const char *key)
 
int xdel (const char *key, const char *id)
 
int xdel (const char *key, const std::vector< string > &ids)
 
int xdel (const char *key, const std::vector< const char * > &ids)
 
int xtrim (const char *key, size_t maxlen, bool tilde=false)
 
bool xread (redis_stream_messages &messages, const std::map< string, string > &streams, size_t count=1000, ssize_t block=0)
 
bool xreadgroup (redis_stream_messages &messages, const char *group, const char *consumer, const std::map< string, string > &streams, size_t count=1000, ssize_t block=0, bool noack=false)
 
bool xreadgroup_with_noack (redis_stream_messages &messages, const char *group, const char *consumer, const std::map< string, string > &streams, size_t count=1000, ssize_t block=0)
 
bool xrange (redis_stream_messages &messages, const char *key, const char *start="-", const char *end="+", size_t count=1000)
 
bool xrevrange (redis_stream_messages &messages, const char *key, const char *start="+", const char *end="-", size_t count=1000)
 
bool xclaim (std::vector< redis_stream_message > &messages, const char *key, const char *group, const char *consumer, long min_idle_time, const std::vector< string > &ids, size_t idle=0, long long time_ms=-1, int retry_count=-1, bool force=false)
 
bool xclaim_with_justid (std::vector< string > &messages_ids, const char *key, const char *group, const char *consumer, long min_idle_time, const std::vector< string > &ids, size_t idle=0, long long time_ms=-1, int retry_count=-1, bool force=false)
 
int xack (const char *key, const char *group, const char *id)
 
int xack (const char *key, const char *group, const std::vector< string > &ids)
 
int xack (const char *key, const char *group, const std::vector< const char * > &ids)
 
int xack (const char *key, const char *group, const std::list< string > &ids, size_t size)
 
int xack (const char *key, const char *group, const std::list< const char * > &ids, size_t size)
 
bool xpending_summary (const char *key, const char *group, redis_pending_summary &result)
 
bool xpending_detail (redis_pending_detail &result, const char *key, const char *group, const char *start_id="-", const char *end_id="+", size_t count=1, const char *consumer=NULL)
 
bool xgroup_help (std::vector< string > &result)
 
bool xgroup_create (const char *key, const char *group, const char *id="$", bool mkstream=true)
 
int xgroup_destroy (const char *key, const char *group)
 
bool xgroup_setid (const char *key, const char *group, const char *id="$")
 
int xgroup_delconsumer (const char *key, const char *group, const char *consumer)
 
bool xinfo_help (std::vector< string > &result)
 
bool xinfo_consumers (const char *key, const char *group, std::map< string, redis_xinfo_consumer > &result)
 
bool xinfo_groups (const char *key, std::map< string, redis_xinfo_group > &result)
 
bool xinfo_stream (const char *key, redis_stream_info &result)
 
- Public 成员函数 继承自 acl::redis_command
 redis_command (void)
 
 redis_command (redis_client *conn)
 
 redis_command (redis_client_cluster *cluster)
 
ACL_CPP_DEPRECATED redis_command (redis_client_cluster *cluster, size_t max_conns)
 
 redis_command (redis_client_pipeline *pipeline)
 
virtual ~redis_command (void)
 
void set_check_addr (bool on)
 
void clear (bool save_slot=false)
 
void reset (bool save_slot=false)
 
void set_client (redis_client *conn)
 
redis_clientget_client (void) const
 
const char * get_client_addr (void) const
 
void set_cluster (redis_client_cluster *cluster)
 
ACL_CPP_DEPRECATED void set_cluster (redis_client_cluster *cluster, size_t max_conns)
 
redis_client_clusterget_cluster (void) const
 
void set_pipeline (redis_client_pipeline *pipeline, bool use_mbox=true)
 
redis_client_pipelineget_pipeline (void) const
 
dbuf_poolget_dbuf (void) const
 
redis_result_t result_type (void) const
 
const char * result_status (void) const
 
const char * result_error (void) const
 
size_t result_size (void) const
 
int result_number (bool *success=NULL) const
 
long long int result_number64 (bool *success=NULL) const
 
const char * get_result (size_t i, size_t *len=NULL) const
 
bool eof (void) const
 
const redis_resultget_result (void) const
 
const redis_resultresult_child (size_t i) const
 
const char * result_value (size_t i, size_t *len=NULL) const
 
void set_slice_request (bool on)
 
void set_slice_respond (bool on)
 
const redis_resultrequest (size_t argc, const char *argv[], size_t lens[], size_t nchild=0)
 
const redis_resultrequest (const std::vector< string > &args, size_t nchild=0)
 
const stringrequest_buf (void) const
 
void build_request (size_t argc, const char *argv[], size_t lens[])
 
void hash_slot (const char *key)
 
void hash_slot (const char *key, size_t len)
 
int get_slot (void) const
 
bool is_check_addr (void) const
 
const char * get_addr (const char *info)
 
void set_client_addr (const char *addr)
 
void set_client_addr (redis_client &conn)
 
redis_request * get_request_obj (void) const
 
stringget_request_buf (void) const
 
bool is_slice_req (void) const
 
redis_pipeline_messageget_pipeline_message (void)
 

额外继承的成员函数

- 静态 Public 成员函数 继承自 acl::redis_command
static void build_request (size_t argc, const char *argv[], size_t lens[], string &out)
 
- Protected 成员函数 继承自 acl::redis_command
const redis_resultrun (size_t nchild=0, int *timeout=NULL)
 
void clear_request (void)
 
const redis_result ** scan_keys (const char *cmd, const char *key, int &cursor, size_t &size, const char *pattern, const size_t *count)
 
const redis_result ** scan_keys (const char *cmd, const char *key, size_t klen, int &cursor, size_t &size, const char *pattern, const size_t *count)
 
void build (const char *cmd, const char *key, const std::map< string, string > &attrs)
 
void build (const char *cmd, const char *key, size_t klen, const std::map< string, string > &attrs)
 
void build (const char *cmd, const char *key, const std::map< string, const char * > &attrs)
 
void build (const char *cmd, const char *key, const std::vector< string > &names, const std::vector< string > &values)
 
void build (const char *cmd, const char *key, size_t klen, const std::vector< string > &names, const std::vector< string > &values)
 
void build (const char *cmd, const char *key, const std::vector< const char * > &names, const std::vector< const char * > &values)
 
void build (const char *cmd, const char *key, const char *names[], const char *values[], size_t argc)
 
void build (const char *cmd, const char *key, const int names[], const char *values[], size_t argc)
 
void build (const char *cmd, const char *key, const char *names[], const size_t names_len[], const char *values[], const size_t values_len[], size_t argc)
 
void build (const char *cmd, const char *key, size_t klen, const char *names[], const size_t names_len[], const char *values[], const size_t values_len[], size_t argc)
 
void build (const char *cmd, const char *key, const std::vector< string > &names)
 
void build (const char *cmd, const char *key, size_t klen, const std::vector< string > &names)
 
void build (const char *cmd, const char *key, const std::vector< const char * > &names)
 
void build (const char *cmd, const char *key, const std::vector< int > &names)
 
void build (const char *cmd, const char *key, const char *names[], size_t argc)
 
void build (const char *cmd, const char *key, const char *names[], const size_t lens[], size_t argc)
 
void build (const char *cmd, const char *key, size_t klen, const char *names[], const size_t lens[], size_t argc)
 
void build (const char *cmd, const char *key, const int names[], size_t argc)
 
int get_number (bool *success=NULL)
 
long long int get_number64 (bool *success=NULL)
 
int get_number (std::vector< int > &out)
 
int get_number64 (std::vector< long long int > &out)
 
bool check_status (const char *success="OK")
 
int get_status (std::vector< bool > &out)
 
const char * get_status (void)
 
int get_string (string &buf)
 
int get_string (string *buf)
 
int get_string (char *buf, size_t size)
 
int get_strings (std::vector< string > &result)
 
int get_strings (std::vector< string > *result)
 
int get_strings (std::list< string > &result)
 
int get_strings (std::list< string > *result)
 
int get_strings (std::map< string, string > &result)
 
int get_strings (std::vector< string > &names, std::vector< string > &values)
 
int get_strings (std::vector< const char * > &names, std::vector< const char * > &values)
 
void argv_space (size_t n)
 
void build_request1 (size_t argc, const char *argv[], size_t lens[])
 
void build_request2 (size_t argc, const char *argv[], size_t lens[])
 
void logger_result (const redis_result *result)
 
- Protected 成员函数 继承自 acl::acl::noncopyable
 noncopyable ()
 
 ~noncopyable ()
 
- Protected 属性 继承自 acl::redis_command
dbuf_pooldbuf_
 
bool check_addr_
 
char addr_ [32]
 
redis_clientconn_
 
redis_client_clustercluster_
 
redis_client_pipelinepipeline_
 
bool pipe_use_mbox_
 
int slot_
 
int redirect_max_
 
int redirect_sleep_
 
bool slice_req_
 
stringrequest_buf_
 
redis_request * request_obj_
 
size_t argv_size_
 
const char ** argv_
 
size_t * argv_lens_
 
size_t argc_
 
bool slice_res_
 
redis_pipeline_messagepipe_msg_
 
const redis_resultresult_
 

详细描述

在文件 redis_stream.hpp142 行定义.

构造及析构函数说明

◆ redis_stream() [1/5]

acl::redis_stream::redis_stream ( void  )

◆ redis_stream() [2/5]

acl::redis_stream::redis_stream ( redis_client conn)

◆ redis_stream() [3/5]

acl::redis_stream::redis_stream ( redis_client_cluster cluster)

◆ redis_stream() [4/5]

acl::redis_stream::redis_stream ( redis_client_pipeline pipeline)

◆ redis_stream() [5/5]

ACL_CPP_DEPRECATED acl::redis_stream::redis_stream ( redis_client_cluster cluster,
size_t  max_conns 
)

◆ ~redis_stream()

virtual acl::redis_stream::~redis_stream ( void  )
virtual

成员函数说明

◆ xack() [1/5]

int acl::redis_stream::xack ( const char *  key,
const char *  group,
const char *  id 
)

Removes one message from the pending entries list (PEL) of a stream consumer group.

参数
key{const char*}
group{const char*}
id{const char*}
返回
{int} return integer >= 0 if ok, -1 if error

◆ xack() [2/5]

int acl::redis_stream::xack ( const char *  key,
const char *  group,
const std::vector< string > &  ids 
)

Removes one or multiple message from the pending entries list (PEL) of a stream consumer group.

参数
key{const char*}
group{const char*}
ids{const std::vector<string>&}
返回
{int} return count of messages been acked, return -1 if error

◆ xack() [3/5]

int acl::redis_stream::xack ( const char *  key,
const char *  group,
const std::vector< const char * > &  ids 
)

◆ xack() [4/5]

int acl::redis_stream::xack ( const char *  key,
const char *  group,
const std::list< string > &  ids,
size_t  size 
)

◆ xack() [5/5]

int acl::redis_stream::xack ( const char *  key,
const char *  group,
const std::list< const char * > &  ids,
size_t  size 
)

◆ xadd() [1/4]

bool acl::redis_stream::xadd ( const char *  key,
const std::map< string, string > &  fields,
string result,
const char *  id = "*" 
)

appends the specified stream entry to the stream at the specified key

参数
key{const char*} the specified key of the stream
fields{const std::map<string, string>&} holds all the entries to be appended to the stream, the map's key is the entry's name, and the value is the entry's value
result{string&} will hold the message-id of the added entry
id{const char*} a stream entry ID identifies a given entry inside a stream, default "*" mean that redis-server will choose one ID internal. When the user specified and explicit ID, the ID's format is look like 1526919030474-55 that includes two numbers separated by '-', the minimum valid ID is 0-1 param maxlen {size_t} if > 0, limit the size of the stream
返回
{bool} return true if entry was added successfully, or some error happened which the error reason can be acquied by calling result_error() of the base class redis_command.

◆ xadd() [2/4]

bool acl::redis_stream::xadd ( const char *  key,
const std::vector< string > &  names,
const std::vector< string > &  values,
string result,
const char *  id = "*" 
)

◆ xadd() [3/4]

bool acl::redis_stream::xadd ( const char *  key,
const std::vector< const char * > &  names,
const std::vector< const char * > &  values,
string result,
const char *  id = "*" 
)

◆ xadd() [4/4]

bool acl::redis_stream::xadd ( const char *  key,
const char *  names[],
const size_t  names_len[],
const char *  values[],
const size_t  values_len[],
size_t  argc,
string result,
const char *  id = "*" 
)

◆ xadd_with_maxlen()

bool acl::redis_stream::xadd_with_maxlen ( const char *  key,
size_t  maxlen,
const std::map< string, string > &  fields,
string result,
const char *  id = "*" 
)

◆ xclaim()

bool acl::redis_stream::xclaim ( std::vector< redis_stream_message > &  messages,
const char *  key,
const char *  group,
const char *  consumer,
long  min_idle_time,
const std::vector< string > &  ids,
size_t  idle = 0,
long long  time_ms = -1,
int  retry_count = -1,
bool  force = false 
)

In the context of a stream consumer group, this command changes the ownership of a pending message, so that the new owner is the consumer specified as the command argument.

参数
messages{std::vector<redis_stream_message>&} holds the messages been XLAIMed
key{const char*}
group{const char*}
consumer{const char*}
min_idle_time{long}
ids{const std::vector<string>&} the IDs to be XCLAIMed
idle{size_t}
time_ms{long long}
retry_count{int}
force{bool}
返回
{bool}

◆ xclaim_with_justid()

bool acl::redis_stream::xclaim_with_justid ( std::vector< string > &  messages_ids,
const char *  key,
const char *  group,
const char *  consumer,
long  min_idle_time,
const std::vector< string > &  ids,
size_t  idle = 0,
long long  time_ms = -1,
int  retry_count = -1,
bool  force = false 
)

XCLAIM with the JUSTID subcommand

◆ xdel() [1/3]

int acl::redis_stream::xdel ( const char *  key,
const char *  id 
)

removes the specified entries from a stream, and returns the number of entries deleted, that may be different from the number of IDs passed to the command in case certain IDs do not exist.

参数
key{const char*} the specified key of the stream
id{const char*} a stream entry ID look like 1526919030474-55
返回
{int} return the number of entries actually deleted, if some error happened -1 will be returned.

◆ xdel() [2/3]

int acl::redis_stream::xdel ( const char *  key,
const std::vector< string > &  ids 
)

removes some entries with the specified IDs, and returns the number of entries deleted.

参数
key{const char*}
ids{const std::vector<string>&} holds the entries' IDs to be deleted
返回
{int}

◆ xdel() [3/3]

int acl::redis_stream::xdel ( const char *  key,
const std::vector< const char * > &  ids 
)

◆ xgroup_create()

bool acl::redis_stream::xgroup_create ( const char *  key,
const char *  group,
const char *  id = "$",
bool  mkstream = true 
)

The XGROUP command with the subcommand CREATE

参数
key{const char*}
group{const char*}
id{const char*} the ID of the last item in the stream to consider already delivered, "$" means the ID of the last item in the stream
mkstream{bool} when mkstream is true, the stream with the specified key will be created if the stream doesn't exist
返回
{bool}

◆ xgroup_delconsumer()

int acl::redis_stream::xgroup_delconsumer ( const char *  key,
const char *  group,
const char *  consumer 
)

The XGROUP command with the subcommand DELCONSUMER. With this command, just remove a given consumer from a consumer group.

参数
key{const char*}
group{const char*}
consumer{const char*}
返回
{int} return the number of the pending messages for the specified consumer, return -1 if error

◆ xgroup_destroy()

int acl::redis_stream::xgroup_destroy ( const char *  key,
const char *  group 
)

The XGROUP command with the subcommand DESTROY. With this command, the consumer group will be destroyed even if there are active consumers and pending messages, so make sure to call this command only when really needed.

参数
key{const char*}
group{const char*}
返回
{int} return the number of pending messages for the specified group, return -1 if error

◆ xgroup_help()

bool acl::redis_stream::xgroup_help ( std::vector< string > &  result)

The XGROUP command with the subcommand HELP

参数
result{std::vector<string>&} will hold the result
返回
{bool}

◆ xgroup_setid()

bool acl::redis_stream::xgroup_setid ( const char *  key,
const char *  group,
const char *  id = "$" 
)

◆ xinfo_consumers()

bool acl::redis_stream::xinfo_consumers ( const char *  key,
const char *  group,
std::map< string, redis_xinfo_consumer > &  result 
)

The XINFO command with the subcommand CONSUMERS. With this command, every consumer in a specific consumer group can be got.

参数
key{const char*}
group{const char*}
result{std::map<string, redis_xinfo_consumer>&}
返回
{bool}

◆ xinfo_groups()

bool acl::redis_stream::xinfo_groups ( const char *  key,
std::map< string, redis_xinfo_group > &  result 
)

The XINFO command with the subcommand GROUPS.

参数
key{const char*}
result{std::map<string, redis_xinfo_group>&}
返回
{bool}

◆ xinfo_help()

bool acl::redis_stream::xinfo_help ( std::vector< string > &  result)

The XINFO command with the subcommand HELP

参数
result{std::vector<string>&}
返回
{bool}

◆ xinfo_stream()

bool acl::redis_stream::xinfo_stream ( const char *  key,
redis_stream_info result 
)

The XINFO command with the subcommand STREAM. In this form the command returns general information about the stream stored at the specified key.

参数
key{const char*}
result{redis_stream_info&} devined about
返回
{bool}

◆ xlen()

int acl::redis_stream::xlen ( const char *  key)

returns the number of entries inside a stream.

参数
key{const char*} the specified key of the stream
返回
{int} value >= 0 if the command was executed correctly, -1 will returned if some error happened.

◆ xpending_detail()

bool acl::redis_stream::xpending_detail ( redis_pending_detail result,
const char *  key,
const char *  group,
const char *  start_id = "-",
const char *  end_id = "+",
size_t  count = 1,
const char *  consumer = NULL 
)

The XPENDING command with DETAIL subcommand.

参数
result{redis_pending_summary&} defined above
key{const char*}
group{const char*}
start_id{const char*}
end_id{const char*}
count{size_t} limit the max count to be saved in result
consumer{const char*}
返回
{bool}

◆ xpending_summary()

bool acl::redis_stream::xpending_summary ( const char *  key,
const char *  group,
redis_pending_summary result 
)

The XPENDING command with SUMMARY subcommand.

参数
key{const char*}
group{const char*}
result{redis_pending_summary&} defined above
返回
{bool}

◆ xrange()

bool acl::redis_stream::xrange ( redis_stream_messages messages,
const char *  key,
const char *  start = "-",
const char *  end = "+",
size_t  count = 1000 
)

The command returns the stream entries matching a given range of IDs.

参数
messages{redis_stream_messages&}
key{const char*}
start{const char*} the start ID of the query interval; '-' means starting from the minimum ID possible inside a stream
end{const char*} the end ID of the query interval; '+' means the end of the maximum ID possible inside a stream
count{size_t} reduce the number of entries reported
返回
{bool}

◆ xread()

bool acl::redis_stream::xread ( redis_stream_messages messages,
const std::map< string, string > &  streams,
size_t  count = 1000,
ssize_t  block = 0 
)

read data from one or multiple streams, only returning entries with an ID greater than the last received ID reported by the caller.

参数
messages{redis_stream_messages&} will hold the read's items, redis_stream_messages defined above
streams{const std::map<string, string>&} holds the specified streams' keys to be read by users
count{size_t} specifies the max count of items to be read, no limit when 0 was set
block{ssize_t} specifies the read timeout, block if 0 set, no-block if -1 set
返回
{bool} return the status of executing the xread command

◆ xreadgroup()

bool acl::redis_stream::xreadgroup ( redis_stream_messages messages,
const char *  group,
const char *  consumer,
const std::map< string, string > &  streams,
size_t  count = 1000,
ssize_t  block = 0,
bool  noack = false 
)

the XREADGROUP command is a special version of the XREAD command with support for consumer groups.

参数
messages{redis_stream_messages&}
group{const char*} the consumer group
consumer{const char*} the consumer belonging to the group
streams{const std::map<string, string>&} holds the streams' keys and IDs for each streams, the map's key is the stream's key and the map's value is the stream's ID option, which can be one of the following two:
  1. The special > ID, which means that the consumer want to receive only messages that were never delivered to any other consumer. It just means, give me new messages.
  2. Any other ID, that is, 0 or any other valid ID or incomplete ID (just the millisecond time part), will have the effect of returning entries that are pending for the consumer sending the command. So basically if the ID is not >, then the command will just let the client access its pending entries: delivered to it, but not yet acknowledged.
count{size_t}
block{ssize_t} set the blocked timeout waiting for messages, if block is 0, will block until getting one message at least; if block is -1, don't block for messages.
noack{bool} The NOACK subcommand can be used to avoid adding the message to the PEL in cases where reliability is not a requirement and the occasional message loss is acceptable. This is equivalent to acknowledging the message when it is read.
返回
{bool} return the status of xreadgroup command

◆ xreadgroup_with_noack()

bool acl::redis_stream::xreadgroup_with_noack ( redis_stream_messages messages,
const char *  group,
const char *  consumer,
const std::map< string, string > &  streams,
size_t  count = 1000,
ssize_t  block = 0 
)

the XREADGROUP with NOACK subcommand for reading messages.

参数
messages{redis_stream_messages&}
group{const char*}
consumer{const char*}
streams{const std::map<string, string>&}
count{size_t}
block{ssize_t}
返回
{bool}

◆ xrevrange()

bool acl::redis_stream::xrevrange ( redis_stream_messages messages,
const char *  key,
const char *  start = "+",
const char *  end = "-",
size_t  count = 1000 
)

Return a range of elements in a stream, with IDs matching the specified IDs interval, in reverse order (from greater to smaller IDs) compared to XRANGE.

参数
messages{redis_stream_messages&}
key{const char*}
start{const char*} start with the higher ID
end(const char*} end with the lower ID
count{size_t}
返回
{bool}

◆ xtrim()

int acl::redis_stream::xtrim ( const char *  key,
size_t  maxlen,
bool  tilde = false 
)

trims the stream to a given number of items, evicting older items (items with lower IDs) if needed.

参数
key{const char*}
maxlen{size_t} specify the latest exactly items to be deleted
tilde{bool} if true, the number of items to be deleted is not exactly equal the maxlen, the real number maybe more than the maxlen with a few tens, but never less than the maxlen
返回
return the number of entries deleted from the stream

该类的文档由以下文件生成: