Skip to content

Repository files navigation

nplex-cpp

The official C++20 client library for nplex — a reactive, key-value database with ACID guarantees designed for scenarios where low-latency reads, real-time change notifications, and minimal resource consumption matter.

Features

  • High performance — A single client can sustain >40,000 commits/s on modest hardware (NUC7i7BNH).
  • Blazing-fast reads — Data lives in client memory; reads never hit the server.
  • Multi-thread support — Multiple threads can create and submit transactions concurrently.
  • Three isolation levelsREAD_COMMITTED, REPEATABLE_READ, and SERIALIZABLE.
  • Reactor pattern — Register a reactor to receive real-time change notifications on every commit.
  • ACID transactions — Atomic, Consistent, Isolated, and Durable.
  • Flexible connection — Automatic reconnection and configurable timeout/back-pressure parameters.
  • Comprehensive tests — Unit tests, covering messaging, transactions, storage, address parsing, and more.

Building

Prerequisites

Install the required shared libraries before building:

  • libuv — cross-platform asynchronous I/O.
  • {fmt} — string formatting library.
  • flatbuffers — memory-efficient serialization library (including the flatc compiler).

Compilation

mkdir -p build
cd build
# Normal build (Release)
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j$(nproc)

Other Targets

# Debug build (default)
cmake -DCMAKE_BUILD_TYPE=Debug ..
make -j$(nproc)# Run unit tests
ctest -V
# AddressSanitizer + UndefinedBehaviorSanitizer
cmake -DENABLE_SANITIZERS=ON ..
make -j$(nproc)
ctest -V
# ThreadSanitizer
cmake -DENABLE_THREAD_SANITIZER=ON ..
make -j$(nproc)
ctest -V
# Profiling
cmake -DENABLE_PROFILER=ON ..
make -j$(nproc)
./example1
gprof ./example1 gmon.out
# Coverage
cmake -DENABLE_COVERAGE=ON ..
make -j$(nproc)
ctest -V
# Valgrind — memory check
valgrind --tool=memcheck --leak-check=yes ./example1
# Valgrind — thread check
valgrind --tool=helgrind --read-var-info=yes ./example1
# Count lines of code (excluding generated files)
cloc --exclude-content="automatically generated" include src test# Static analysis
cppcheck --enable=all --inconclusive --std=c++20 --force \
--suppress=missingIncludeSystem --suppress=unusedFunction \
--suppress=useInitializationList --suppress=noExplicitConstructor \
--suppress=cstyleCast -Ideps -Isrc -Iinclude src
# clang-tidy (uncomment CMAKE_CXX_CLANG_TIDY in CMakeLists.txt)
cmake ..
make -j$(nproc)

Examples & Tools

BinaryTypePurpose
example1ExampleMinimal connection, read, ping and submit demo
functestsToolFunctional tests for isolation levels
flooderToolPerformance/load generator for write traffic
watcherToolPrints DB/session snapshots and streams updates in JSON

All binaries support -h / --help, where the available parameters are documented.

Dependencies

Static

LibraryDescriptionLicense
FastGlobbingWildcard pattern matchingCPOL
cstringImmutable C-string with reference countingLGPL-3.0
cqueueCircular queueLGPL-3.0
base64Base64 encoder / decoderMIT
utf8.hUTF-8 string functionsUnlicense
doctestTesting frameworkMIT license

Shared

LibraryDescriptionLicense
{fmt}String formattingMIT
libuvCross-platform async I/OMIT
flatbuffersEfficient binary serializationApache-2.0

Maintainers

This project is maintained by Gerard Torrent (torrentg).

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

C++ client to access the nplex database

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages