Skip to content

torrentg/nplex-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 -DENABLE_THREAD_SANITIZER=OFF ..
make -j$(nproc)
ctest -V

# ThreadSanitizer
cmake -DENABLE_SANITIZERS=OFF -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

Binary Type Purpose
example1 Example Minimal connection, read, ping and submit demo
functests Tool Functional tests for isolation levels
flooder Tool Performance/load generator for write traffic
watcher Tool Prints DB/session snapshots and streams updates in JSON

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

Dependencies

Static

Library Description License
FastGlobbing Wildcard pattern matching CPOL
cppcrc Header-only CRC generation MIT
cstring Immutable C-string with reference counting LGPL-3.0
cqueue Circular queue LGPL-3.0
base64 Base64 encoder / decoder MIT
utf8.h UTF-8 string functions Unlicense
doctest Testing framework MIT license

Shared

Library Description License
{fmt} String formatting MIT
libuv Cross-platform async I/O MIT
flatbuffers Efficient binary serialization Apache-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

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors