代码拉取完成,页面将自动刷新
/*
* @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;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。