Skip to content
hanzoaiPublic

About

Ultra-fast key-value store with Redis API compatibility

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

27,334 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

kv

Hanzo KV

High-performance key-value store for the Hanzo ecosystem.
In-memory data store used as database, cache, streaming engine, and message broker.

CI Release License


Features

Open in Hanzo Edit with Hanzo Deploy with Hanzo

  • In-memory key-value store -- sub-millisecond reads and writes
  • RESP protocol -- speaks RESP2 and RESP3, so existing clients connect unchanged
  • Persistence -- RDB snapshots and AOF (append-only file) for durability
  • Replication -- primary-replica with automatic failover via Sentinel
  • Lua scripting -- server-side scripting for atomic operations
  • Pub/Sub -- publish and subscribe messaging
  • Streams -- append-only log data structure for event sourcing
  • Cluster mode -- horizontal scaling with automatic sharding
  • Modules -- extensible plugin system for custom data structures
  • ZAP native -- built-in ZAP binary protocol on port 9653 (17x faster than JSON-RPC)
  • Multi-arch -- linux/amd64 and linux/arm64

Quick Start

Docker

docker run -d --name hanzo-kv -p 6379:6379 -p 9653:9653 ghcr.io/hanzoai/kv:9.1.0

Connect

docker exec -it hanzo-kv kv

127.0.0.1:6379> SET hello world
OK
127.0.0.1:6379> GET hello
"world"

Any RESP client also works out of the box.

Build from Source

On Debian or Ubuntu, install build-essential for the compiler and Make, tcl for the test runner, and procps for the tests that use ps:

sudo apt-get install build-essential tcl procps

On macOS, install the Xcode Command Line Tools (xcode-select --install). For tests, make sure a versioned Tcl executable supported by runtest (tclsh8.5, tclsh8.6, or tclsh9.0) is on your PATH.

make
make test
make install

To run just the suites covering core Redis protocol commands, use:

./runtest --single unit/type/string --single unit/type/hash \
  --single unit/type/list --single unit/expire --single unit/pubsub

For a quick throughput baseline against a disposable local server, run src/kv-benchmark -h 127.0.0.1 -p 6379 -n 100000 -c 50 -t set,get. Record the build, hardware, and client settings alongside the result.

CLI Tools

Command Description
kv Interactive CLI (default)
kv-server Start KV server
kv-cli Command-line client
kv-sentinel High-availability sentinel
kv-benchmark Performance benchmarking
kv-check-aof AOF file integrity check
kv-check-rdb RDB file integrity check

Configuration

Pass a config file at startup:

kv-server /etc/kv/kv.conf

Or set options via command line:

kv-server --port 6379 --maxmemory 256mb --appendonly yes

ZAP Binary Protocol

Hanzo KV speaks ZAP natively on port 9653 via the module in modules/zap — no sidecar needed. ZAP is a zero-copy binary protocol that's 17x faster than JSON-RPC with 11x less memory usage.

ghcr.io/hanzoai/kv:9.1.0 ships with /usr/lib/kv/modules/zap.so compiled into the image and enabled by default on port 9653.

Configure ZAP

When running from source or customizing the port:

# Build module
make -C modules/zap

# Load with default port (9653, or KV_ZAP_PORT env var):
kv-server --loadmodule /usr/lib/kv/modules/zap.so

# Or override the port on the CLI (use PORT <n>; or --port / --port= in kv.conf or MODULE LOAD):
kv-server --loadmodule /usr/lib/kv/modules/zap.so PORT 9653
# In kv.conf:
#   loadmodule /usr/lib/kv/modules/zap.so --port=9653

ZAP Operations

Path Body Description
/get {"key":"mykey"} GET a key
/set {"key":"mykey","value":"myval"} SET a key
/del {"key":"mykey"} DEL a key
/cmd {"cmd":"PING","args":[]} Execute any command

Module API

Develop custom modules using the KV Module API:

#include "kvmodule.h"

int KVModule_OnLoad(KVModuleCtx *ctx, KVModuleString **argv, int argc) {
    if (KVModule_Init(ctx, "mymod", 1, KVMODULE_APIVER_1) == KVMODULE_ERR)
        return KVMODULE_ERR;
    // register commands...
    return KVMODULE_OK;
}

Client SDKs

Language Package Install
Python hanzo-kv pip install hanzo-kv
Go hanzokv/go go get github.com/hanzokv/go/v9
Node.js hanzokv/js npm install @hanzo/kv

Any RESP client library will also work.

Documentation

Full documentation is available at docs.hanzo.ai.

License

BSD-3-Clause

Copyright (c) 2024-2026 Hanzo AI Inc. All rights reserved.

About

Ultra-fast key-value store with Redis API compatibility

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages