11# cpp_redis
22cpp_redis is C++11 Asynchronous Redis Client.
33
4- Network is based on Boost Asio library.
4+ Network is based on raw sockets API. This, library is really lightweight .
55
66## Requirements
77* C++11
8- * Boost Asio
98
109## Compiling
1110The library uses ` cmake ` . In order to build the library, follow these steps:
@@ -62,7 +61,7 @@ Reply callback is an `std::function<void(reply&)>`.
6261### Example
6362
6463``` cpp
65- #include " cpp_redis/cpp_redis"
64+ #include < cpp_redis/cpp_redis>
6665
6766#include < signal.h>
6867#include < iostream>
@@ -72,28 +71,31 @@ cpp_redis::redis_client client;
7271
7372void
7473sigint_handler(int) {
75- std::cout << "disconnected (sigint handler)" << std::endl;
76- client.disconnect();
74+ std::cout << "disconnected (sigint handler)" << std::endl;
75+ client.disconnect();
76+ should_exit = true;
7777}
7878
7979int
8080main(void) {
81- client.set_disconnection_handler([ ] (cpp_redis::redis_client&) {
82- std::cout << "client disconnected (disconnection handler)" << std::endl;
83- should_exit = true;
84- });
81+ client.set_disconnection_handler([ ] (cpp_redis::redis_client&) {
82+ std::cout << "client disconnected (disconnection handler)" << std::endl;
83+ should_exit = true;
84+ });
8585
86- client.connect();
86+ client.connect();
8787
88- client.send({"SET", "hello", "world"});
89- client.send({"GET", "hello"}, [] (cpp_redis::reply& reply) {
90- std::cout << reply.as_string() << std::endl;
91- });
88+ client.send({"SET", "hello", "world"}, [ ] (cpp_redis::reply& reply) {
89+ std::cout << reply.as_string() << std::endl;
90+ });
91+ client.send({"GET", "hello"}, [ ] (cpp_redis::reply& reply) {
92+ std::cout << reply.as_string() << std::endl;
93+ });
9294
93- signal(SIGINT, &sigint_handler);
94- while (not should_exit);
95+ signal(SIGINT, &sigint_handler);
96+ while (not should_exit);
9597
96- return 0;
98+ return 0;
9799}
98100```
99101
@@ -133,7 +135,7 @@ Unsubscribe from the given pattern.
133135### Example
134136
135137```cpp
136- #include " cpp_redis/cpp_redis"
138+ #include < cpp_redis/cpp_redis>
137139
138140#include <signal.h>
139141#include <iostream>
145147sigint_handler(int) {
146148 std::cout << "disconnected (sigint handler)" << std::endl;
147149 sub.disconnect();
150+ should_exit = true;
148151}
149152
150153int
0 commit comments