1 Star 0 Fork 0

lasyman/redisclientpp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
redisclient-test.cpp 1.68 KB
一键复制 编辑 原始数据 按行查看 历史
allen.xing 提交于 2019-07-24 14:55 . first commit
/*
* @Author: allen.xing
* @Date: 2019-07-22 18:51:41
* @Last Modified by: allen.xing
* @Last Modified time: 2019-07-22 19:03:10
*/
#include "src/redisclientpp.h"
#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/address.hpp>
redisclient::RedisSyncClient con()
{
boost::asio::ip::address address = boost::asio::ip::address::from_string("127.0.0.1");
const unsigned short port = 6379;
boost::asio::ip::tcp::endpoint endpoint(address, port);
boost::asio::io_service ioService;
redisclient::RedisSyncClient redis(ioService);
boost::system::error_code ec;
redis.connect(endpoint, ec);
if(ec)
{
std::cerr << "Can't connect to redis: " << ec.message() << std::endl;
}
return redis;
}
int main(int argc, char const *argv[])
{
std::cout << "==================" << std::endl;
RedisClientPP *redisClient = new RedisClientPP();
if (redisClient->connectToHost("127.0.0.1")) {
redisClient->set_hash_data("devs", "192.168.1.49", "AGV1");
std::cout << redisClient->get_hash_data("devs", "192.168.1.49") << std::endl;
multimap<string, string> data;
data.insert(pair<string, string>("key1", "value1"));
data.insert(pair<string, string>("key2", "value2"));
redisClient->set_hash_mdata("map", data);
multimap<string, string> values = redisClient->get_hash_all("map");
string keys;
for(string str : redisClient->get_hash_keys("map"))
keys.append(str + " ");
cout << keys << endl;
vector<string> list = redisClient->list_range("list", 0, 2);
for (string str : list)
cout << str << " ";
cout << endl;
}
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lasyman/redisclientpp.git
git@gitee.com:lasyman/redisclientpp.git
lasyman
redisclientpp
redisclientpp
master

搜索帮助