A high-performance Zig client for the Phage key-value database. Demon provides both interactive (REPL) and command-line interfaces for connecting to Phage servers.
- Dual Interface: Interactive REPL mode or single command execution
- Full Protocol Support: All Phage commands (SET, GET, DELETE, KEYS, PING, BENCHMARK)
- ZeroMQ Networking: High-performance communication with Phage servers
- Cross-platform: Works on Linux, macOS, and Windows
- Zig 0.11+
- ZeroMQ library (
libzmq)
zig buildThe executable will be created at zig-out/bin/demon.
./zig-out/bin/demonThis starts an interactive session where you can type commands:
demon> SET mykey "hello world"
OK
demon> GET mykey
hello world
demon> DELETE mykey
OK
demon> PING
PONG
demon> exit
Execute single commands directly:
# Health check
./zig-out/bin/demon PING
# Store a value
./zig-out/bin/demon SET user:123 "Alice Johnson"
# Retrieve a value
./zig-out/bin/demon GET user:123
# Delete a key
./zig-out/bin/demon DELETE user:123
# Pattern matching
./zig-out/bin/demon KEYS "user:*"
# Performance testing
./zig-out/bin/demon BENCHMARK 1000| Command | Description | Example |
|---|---|---|
SET key value |
Store a key-value pair | SET name "John" |
GET key |
Retrieve value for key | GET name |
DELETE key |
Remove a key | DELETE name |
KEYS pattern |
Find keys matching pattern | KEYS "user:*" |
PING |
Health check | PING |
BENCHMARK n |
Run performance test | BENCHMARK 1000 |
The KEYS command supports pattern matching:
*matches any charactersuser:*matches all keys starting with "user:"*:profilematches all keys ending with ":profile"
Demon connects to tcp://localhost:5555 by default. To connect to a different Phage server, modify the connection string in src/main.zig.
# Store multiple users
./demon SET user:1 "Alice"
./demon SET user:2 "Bob"
./demon SET user:3 "Charlie"
# Find all users
./demon KEYS "user:*"
# Performance test
./demon BENCHMARK 10000#!/bin/bash
# Health check script
if ./demon PING > /dev/null 2>&1; then
echo "Phage server is healthy"
exit 0
else
echo "Phage server is down"
exit 1
fisrc/main.zig- Main application and CLI handlingsrc/root.zig- Core client librarybuild.zig- Build configurationbuild.zig.zon- Dependencies
- zimq - ZeroMQ bindings for Zig
This project is licensed under the MIT License - see the LICENSE file for details.
- Phage - The high-performance key-value database server