Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tair-opensource/tair-client
A C++ client for connecting to Tair, fully Redis compatible.
https://github.com/tair-opensource/tair-client
nosql redis-client tair
Last synced: about 2 months ago
JSON representation
A C++ client for connecting to Tair, fully Redis compatible.
- Host: GitHub
- URL: https://github.com/tair-opensource/tair-client
- Owner: tair-opensource
- License: mit
- Created: 2023-09-04T03:27:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-30T11:19:30.000Z (about 1 year ago)
- Last Synced: 2024-02-22T12:28:31.928Z (10 months ago)
- Topics: nosql, redis-client, tair
- Language: C++
- Homepage:
- Size: 18.3 MB
- Stars: 12
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tair C++ Client
Tair C++ Client is a client used to connect to Tair, it can also be used to connect to Redis, because Tair is fully compatible with Redis.
- Asynchronous and provides a synchronous future interface
- Support Standalone and Cluster
- Support seamless switching capabilities [WIP]
- Support rust, go, python interfaces [WIP]# How to Use
1. build deps
```
./bootstrap.sh deps release[debug]
```2. build source
```
./bootstrap.sh build release[debug]
```3. [optional] start redis at `tests/ut_tests/client/TairClient_Standalone_Server.cpp#STANDALONE_ADDR`(default: 127.0.0.1:6379) and run test
```
./bootstrap.sh test
```# Example
```
#include "client/TairClient.hpp"
#include "client/TairResult.hpp"
#include "common/CountDownLatch.hpp"#include
using tair::client::TairClient;
using tair::client::TairURI;
using tair::client::TairResult;
using tair::common::CountDownLatch;int main(int argc, char *argv[]) {
// connect
auto *client = new TairClient();
TairURI uri = TairURI::create()
.type(TairURI::STANDALONE)
.serverAddrs({"127.0.0.1:6379"})
.connectingTimeoutMs(3000)
.build();
if (!client->init(uri).isSuccess()) {
std::cerr << "Connect error, see logs for detail" << std::endl;
}// sync usage
auto wrapper = client->getFutureWrapper();
std::future> f = wrapper.set("key", "value");
if (f.get().isSuccess()) {
std::cout << "set key success" << std::endl;
} else {
std::cerr << "set key fail" << std::endl;
}// async usage, we need a latch to pending
CountDownLatch latch;
client->get("key", [&](const TairResult> &result) {
latch.countDown();
if (result.isSuccess()) {
std::cout << "get key: " << *(result.getValue()) << std::endl;
} else {
std::cerr << "get key fail" << std::endl;
}
});
latch.wait();
// destroy
client->destroy();
}
```
For more examples please refer to the examples directory.