A simple Aerospike client that allows you to receive binary data by namespace and key
I tried to use standard libraries - std and Boost. However, when sending a request to the server, the key is encrypted with RIPEMD-160, so I connected the OpenSSL library.
This project can be used to connect to an existing Aerospike server for subsequent receipt of binary data from it (strings, as well as integer and fractional numbers). You can also use connection pooling to maximize performance.
- Speed of work.
- Connections pooling.
- Install Boost (tested on version ≥ 1.50)
- Install OpenSSL (tested on version ≥ 1.1)
- Clone project:
git clone https://github.com/DaniilChizhevskii/AerospikeGetClient
- Set your folder to project folder:
cd AerospikeGetClient
- Make examples:
make
#include "AerospikeClient.h"
#include <iostream>
#include <variant>
#include <map>
...
AerospikeClient client("127.0.0.1", 3000); // Host & Port
client.get("namespace", "key"); // Namespace & Key
for (auto const &iterator : client.result) {
std::cout << iterator.first << ": \"";
std::visit([](const auto &elem) {
std::cout << elem << "\"." << std::endl;
}, iterator.second);
}
#include "AerospikePool.h"
#include <iostream>
#include <variant>
#include <map>
...
AerospikePool pool("127.0.0.1", 3000, 10); // Host & Port & Number of connections in pool
std::map<std::string, std::variant<std::string, long long, double>> result;
result = pool.get("namespace", "key", 20); // Namespace & Key & Timeout in milliseconds
for (auto const &iterator : result) {
std::cout << iterator.first << ": \"";
std::visit([](const auto &elem) {
std::cout << elem << "\"." << std::endl;
}, iterator.second);
}
#include "AerospikePool.h"
#include <iostream>
#include <vector>
...
AerospikePool pool("127.0.0.1", 3000, 10); // Host & Port & Number of connections in pool
...
std::vector<std::tuple<int, double, double>> status = pool.status();
for (int i = 0; i < 10; i++) {
std::cout << "Statistic #" << i + 1 << "." << std::endl
<< std::fixed << std::setprecision(3)
<< "Creation time: " << std::get<1>(status[i])
<< ". Last using time: " << std::get<2>(status[i]) << "."
<< std::endl;
}