acl  3.5.3.0
acl::redis_geo类 参考

#include <redis_geo.hpp>

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

Public 成员函数

 redis_geo ()
 
 redis_geo (redis_client *conn)
 
 redis_geo (redis_client_cluster *cluster)
 
ACL_CPP_DEPRECATED redis_geo (redis_client_cluster *cluster, size_t max_conns)
 
 redis_geo (redis_client_pipeline *pipeline)
 
virtual ~redis_geo ()
 
int geoadd (const char *key, const char *member, double longitude, double latitude)
 
int geoadd (const char *key, size_t size, const char *members[], const double longitudes[], const double latitudes[])
 
int geoadd (const char *key, const std::vector< string > &members, const std::vector< double > &longitudes, const std::vector< double > &latitudes)
 
bool geohash (const char *key, const std::vector< string > &members, std::vector< string > &results)
 
bool geohash (const char *key, const char *member, string &result)
 
bool geopos (const char *key, const std::vector< string > &members, std::vector< std::pair< double, double > > &results)
 
bool geopos (const char *key, const char *member, std::pair< double, double > &result)
 
double geodist (const char *key, const char *member1, const char *member2, int unit=GEO_UNIT_M)
 
const std::vector< geo_member > & georadius (const char *key, double longitude, double latitude, double radius, int unit=GEO_UNIT_M, int with=GEO_WITH_COORD|GEO_WITH_DIST, int sort=GEO_SORT_ASC)
 
const std::vector< geo_member > & georadiusbymember (const char *key, const char *member, double radius, int unit=GEO_UNIT_M, int with=GEO_WITH_COORD|GEO_WITH_DIST, int sort=GEO_SORT_ASC)
 
- 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_geo.hpp95 行定义.

构造及析构函数说明

◆ redis_geo() [1/5]

acl::redis_geo::redis_geo ( )

◆ redis_geo() [2/5]

acl::redis_geo::redis_geo ( redis_client conn)

◆ redis_geo() [3/5]

acl::redis_geo::redis_geo ( redis_client_cluster cluster)

◆ redis_geo() [4/5]

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

◆ redis_geo() [5/5]

acl::redis_geo::redis_geo ( redis_client_pipeline pipeline)

◆ ~redis_geo()

virtual acl::redis_geo::~redis_geo ( )
virtual

成员函数说明

◆ geoadd() [1/3]

int acl::redis_geo::geoadd ( const char *  key,
const char *  member,
double  longitude,
double  latitude 
)

添加一个指定的地理位置坐标至指定的 key 中 Add the specified geospatial item (latitude, logitude, name) to the specified key.

参数
key{const char*} 对应的键值 the specified key
member{const char*} 该地理坐标的标识符 the geospatial's identifier
longitude{double} 经度 the geospatial's loginitude
latitude{double} 纬度 the geospatial's latitude
返回
{int} 1:添加成功,0:该地理坐标标识符已存在,即使对其值进行了修改, 也将返回 0,-1:表示出错。 the return value as below: 1: add one new member successfully 0: the member already existed, and the geospatial may be changed -1: some erro happened

◆ geoadd() [2/3]

int acl::redis_geo::geoadd ( const char *  key,
size_t  size,
const char *  members[],
const double  longitudes[],
const double  latitudes[] 
)

给指定 key 添加一组地址位置坐标数据 Add the specified geospatial items (latitude, logitude, name) to the specified key.

参数
key{const char*} 对应的键值 the specified key
size{size_t} 数组的长度 the array's size
members{const char* []} 成员数组,其长度由 size 指定 the members array, which's length was specified by size parameter
longitudes{const double[]} 经度数据数组,其长度由 size 指定 the logintitudes array, which's length was specifed by size parameter
latitudes{const double[]} 纬度数据数组,其长度由 size 指定 the lattitudes array, which's length was specifed by size parameter
返回
{int} 添加成功的成员数量,返回值含义如下: return the successfully added members's count:

0: 表示成功添加的成员数量;

represent the successfully added members's count 0: 这些成员都已经存在 the members's belong the key already existing -1: 表示出错,可以通过 result_error 函数查看出错原因 some error happened, the result_error function can be used to find the error's reason

◆ geoadd() [3/3]

int acl::redis_geo::geoadd ( const char *  key,
const std::vector< string > &  members,
const std::vector< double > &  longitudes,
const std::vector< double > &  latitudes 
)

给指定 key 添加一组地址位置坐标数据 Add the specified geospatial items (latitude, logitude, name) to the specified key.

参数
key{const char*} 对应的键值 the specified key
members{const std::vector<string>&} 成员数组 the members array
longitudes{const std::vector<double>&} 经度数据数组 the logintitudes array
latitudes{const std::vector<double>&} 纬度数据数组 the lattitudes array
返回
{int} 添加成功的成员数量,返回值含义如下: return the successfully added members's count:

0: 表示成功添加的成员数量;

represent the successfully added members's count 0: 这些成员都已经存在 the members's belong the key already existing -1: 表示出错,可以通过 result_error 函数查看出错原因 some error happened, the result_error function can be used to find the error's reason 注意:三个数组(members, longitudes, latitudes)的数组长度必须相等 Notice: the three array's length must be equal between members, longitudes and latitudes

◆ geodist()

double acl::redis_geo::geodist ( const char *  key,
const char *  member1,
const char *  member2,
int  unit = GEO_UNIT_M 
)

获得两个地理位置坐标之间的距离 Returns the distance between two members of a geospatial index

参数
key{const char*} 对应的键值 the specified key
member1{const char*} 地理坐标成员 one member of a geospatial index
member2{const char*} 地理坐标成员 another member of a geospatial index
unit{int} 返回的距离的单位值
返回
{double} 两个坐标之间的长度,返回值 < 0 表示出错 returns the distance between two members, which was less than 0 if some error happened.

◆ geohash() [1/2]

bool acl::redis_geo::geohash ( const char *  key,
const std::vector< string > &  members,
std::vector< string > &  results 
)

以字符串方式返回指定成员的 GEOHASH 值 Returns members of a geospatial index as standard geohash strings.

参数
key{const char*} 对应的键值 the specified key
members{const std::vector<string>&} 成员数组 the members array
results{std::vector<string>&} 存储结果集合 store the result
返回
{bool} 操作是否成功 if the operation was successful.

◆ geohash() [2/2]

bool acl::redis_geo::geohash ( const char *  key,
const char *  member,
string result 
)

以字符串方式返回指定成员的 GEOHASH 值 Returns members of a geospatial index as standard geohash strings.

参数
key{const char*} 对应的键值 the specified key
member{const char*} 成员名 the member of a geospatial index
result{std::vector<string>&} 存储结果 store the result
返回
{bool} 操作是否成功 if the operation was successful.

◆ geopos() [1/2]

bool acl::redis_geo::geopos ( const char *  key,
const std::vector< string > &  members,
std::vector< std::pair< double, double > > &  results 
)

获得指定成员的地理位置坐标 Returns longitude and latitude of members of a geospatial index

参数
key{const char*} 对应的键值 the specified key
members{const std::vector<string>&} 成员数组 the members array
results{std::vector<std::pair<double, double> >&} 存储结果集 store the results
返回
{bool} 操作是否成功 if the operation was successful.

◆ geopos() [2/2]

bool acl::redis_geo::geopos ( const char *  key,
const char *  member,
std::pair< double, double > &  result 
)

获得某个指定成员的地理位置坐标 Returns longitude and latitude of the one member of a geospatial index

参数
key{const char*} 指定键值 the specifed key
member{const char*} 指定成员名 the specified member
result{std::pair<double, double>&} 存储坐标点结果 store the result of longitude and latitude of the member
返回
{bool} 操作是否成功 if the operation was successful.

◆ georadius()

const std::vector<geo_member>& acl::redis_geo::georadius ( const char *  key,
double  longitude,
double  latitude,
double  radius,
int  unit = GEO_UNIT_M,
int  with = GEO_WITH_COORD|GEO_WITH_DIST,
int  sort = GEO_SORT_ASC 
)

获得距离某指定坐标位置在给定距离范围内的所有坐标点 Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point

参数
key{const char*} 对应的键值 the specified key
longitude{double} 指定坐标点的经度值 the longitude of the specified geospatial coordinate
latitude{double} 指定坐标点的纬度值 the latitude of the specified geospatial coordinate
radius{double} 限定的距离范围大小 the distance from the specified coordinate
unit{int} radius 距离的单位类型 the unit type of the raidus
with{int} 查询条件选项,参见上面的定义:GEO_WITH_XXX the serach operations, defined as GEO_WITH_XXX above
sort{int} 查询结果的排序方式,定义参见:GEO_SORT_XXX the sorted type of the results, defined as GEO_SORT_XXX above
返回
{const std::vector<geo_member>&} 符合条件的坐标点的结果集 Returns the results according the searching conditions.

◆ georadiusbymember()

const std::vector<geo_member>& acl::redis_geo::georadiusbymember ( const char *  key,
const char *  member,
double  radius,
int  unit = GEO_UNIT_M,
int  with = GEO_WITH_COORD|GEO_WITH_DIST,
int  sort = GEO_SORT_ASC 
)

获得距离某指定坐标位置在给定距离范围内的所有坐标点 Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member

参数
key{const char*} 对应的键值 the specified key
member{const char*} 某个指定的坐标点成员 the specified member of a geospatial index
radius{double} 限定的距离范围大小 the distance from the specified coordinate
unit{int} radius 距离的单位类型 the unit type of the raidus
with{int} 查询条件选项,参见上面的定义:GEO_WITH_XXX the serach operations, defined as GEO_WITH_XXX above
sort{int} 查询结果的排序方式,定义参见:GEO_SORT_XXX the sorted type of the results, defined as GEO_SORT_XXX above
返回
{const std::vector<geo_member>&} 符合条件的坐标点的结果集 Returns the results according the searching conditions.

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