A lightweight, high-performance key-value store with both synchronous and asynchronous C++ clients.
- In-memory key-value storage
- Asynchronous network I/O using event loops
- Multiple client implementations:
- Coroutine-based async client (C++20)
- Simple synchronous client
- Support for multiple value types:
- Strings
- Integers
- Floating-point numbers
- Binary data (vector<uint8_t>)
- Parallel operation support
- Clean shutdown handling
- C++20 compiler (for coroutine support)
- CMake 3.15 or higher
- Unix-like operating system (Linux/macOS)
mkdir build
cd build
cmake ..
makeThe service can be started programmatically:
#include "service/service.h"
auto service = radish::create_kv_service();
service->serve(1400); // Start on port 1400The modern C++20 client using coroutines for asynchronous operations:
#include "client/client.h"
// Create a client
radish::client client("localhost", 1400);
// Async operations using co_await
async_result<void> set_value() {
co_await client.set("key", "value");
}
async_result<std::string> get_value() {
std::string value = co_await client.get<std::string>("key");
co_return value;
}The library supports parallel operations using multiple clients:
// Create multiple clients
std::vector<std::unique_ptr<radish::client>> clients;
for (int i = 0; i < num_clients; ++i) {
clients.push_back(std::make_unique<radish::client>("localhost", port));
}
// Perform parallel operations
std::vector<async_result<void>> tasks;
for (auto& client : clients) {
tasks.push_back(client->set("key", "value"));
}
// Wait for all operations to complete
for (auto& task : tasks) {
co_await task;
}The project includes several sample programs demonstrating different usage patterns:
samples/coro_kv_client.cpp: Demonstrates coroutine-based parallel operations with multiple clientssamples/combined_kv_client_server.cpp: Shows how to run both client and server in the same processsamples/event_loop_kv_storage_client.cpp: Example using the event loop based clientsamples/event_loop_kv_storage_client_spawner.cpp: Demonstrates spawning multiple client processes
# Build and run the coroutine-based sample
./samples/coro_kv_client
# Build and run the combined client-server sample
./samples/combined_kv_client_serverThe service uses a simple binary protocol for communication:
- Header format:
{MajorVersion, MinorVersion, Patch, RequestType} - Request types:
- GET: Retrieves a value by key
- SET: Stores a key-value pair
- DUMP: Dumps entire key-value store (not implemented)
The service is designed for high performance:
- Non-blocking I/O using event loops
- Efficient binary protocol
- Support for parallel operations
- Coroutine-based async operations with minimal overhead
MIT License - See LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.