-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathService.cpp
More file actions
37 lines (33 loc) · 1004 Bytes
/
Copy pathService.cpp
File metadata and controls
37 lines (33 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "RedisManager.h"
int main(){
RedisManager* rm;
rm = new RedisManager(redis_IP.c_str(), redis_Port, redis_Timeout);
if(rm->getErrno()){
userlog("ERROR: Fail to connect to REDIS database!");
return -1;
}else{
userlog("Successfully connect to REDIS database!");
}
//Redis变量定义
vector<string> vec_result;
map<string, string> map_result;
map<string, string>::iterator it;
int ret; //执行redis后的返回值
vec_result.clear();
ret = rm->getKeys(cityID.c_str(), vec_result);
if(rm->getErrno()){
LOGERR(READ_REDIS_CITYID_ERR, "CityID %s: rm->getErrstr: %s",cityID.c_str(), rm->getErrstr());
}
ret = rm->hashGetALL(cityID.c_str(), map_result);
if(rm->getErrno()){
LOGERR(READ_REDIS_CITYID_ERR, "CityID %s: rm->getErrstr: %s",cityID.c_str(), rm->getErrstr());
}
it = map_result.find("city_name");
if (it != map_result.end()){
root_res["name_cn"]=it->second;
}
it = map_result.find("city_name_en");
if (it != map_result.end()){
root_res["name_en"]=it->second;
}
}