Skip to content

Latest commit

 

History

History

README.md

Ignix Client Examples

This directory contains client examples demonstrating how to connect to and use Ignix with various programming languages.

Available Examples

1. Rust Client (client.rs)

Basic Rust client using raw TCP sockets and RESP protocol.

cargo run --example client

2. Python Client (python_client.py)

Python client using the redis-py library.

# Install dependencies
pip install -r examples/requirements.txt

# Run example
python3 examples/python_client.py

3. Node.js Client (nodejs_client.js)

Node.js client using the redis npm package.

# Install dependencies
cd examples && npm install

# Run example
node nodejs_client.js

Prerequisites

  1. Start Ignix Server

    cargo run --release

    The server will start on localhost:7379. If you start it with --requirepass PASSWORD, run the Python and Node.js examples with IGNIX_PASSWORD=PASSWORD so they authenticate.

  2. Install Client Dependencies (for Python/Node.js examples, see above)

Supported Operations

All examples demonstrate these Redis-compatible operations:

  • PING - Test server connectivity
  • SET key value - Set a key-value pair
  • GET key - Retrieve a value by key
  • EXISTS key [key ...] - Count how many keys exist
  • INCR key - Increment a numeric value (redis-py sends INCRBY key 1)
  • DEL key [key ...] - Delete keys
  • RENAME oldkey newkey - Rename a key
  • MSET key1 value1 key2 value2 - Set multiple keys
  • MGET key1 key2 key3 - Get multiple values

The Python and Node.js examples also show expiries (SET key value EX 60, TTL, PERSIST, SET key value PX 100) and list their keys with SCAN MATCH *:* and DBSIZE.

Example Output

When running successfully, you should see output similar to:

🔥 Ignix Python Client Example
========================================
Connecting to Ignix server at localhost:7379...
Testing connection...
PING response: True

📝 Basic Operations:
--------------------
Setting key 'hello' to 'world'...
✅ SET hello world
✅ GET hello: world
✅ EXISTS hello: 1

🔢 Counter Operations:
-------------------------
✅ INCR counter: 1
✅ INCR counter: 2
✅ INCR counter: 3
✅ INCR counter: 4
✅ INCR counter: 5

✅ All operations completed successfully!

Troubleshooting

Connection Refused

❌ Connection Error: Could not connect to Ignix server

Solution: Make sure the Ignix server is running:

cargo run --release

Command Not Found

❌ Redis Error: unknown command 'HSET', with args beginning with: 'user' 'name' 'ada'

Solution: The command is not implemented in Ignix yet. Check the supported commands list.

Python Issues

If you get import errors:

pip install "redis>=5.0.0"

Node.js Issues

If you get module not found errors:

cd examples
npm install redis

Writing Your Own Client

Ignix implements the Redis Serialization Protocol (RESP), so any Redis client library should work. Here's a minimal example:

Python (redis-py)

import redis
client = redis.Redis(host='localhost', port=7379, decode_responses=True)
client.set('key', 'value')
print(client.get('key'))

Node.js (redis)

const redis = require('redis');
const client = redis.createClient({ socket: { host: 'localhost', port: 7379 } });
await client.connect();
await client.set('key', 'value');
console.log(await client.get('key'));

Raw RESP Protocol

Any Redis tool can talk to Ignix, for example redis-cli:

redis-cli -p 7379 SET key value
redis-cli -p 7379 GET key

Performance Testing

Micro-benchmarks and the Redis comparison live in benches/ and benchmarks/:

cargo bench --bench exec --bench resp
bash benchmarks/run_benchmarks.sh

See benchmarks/BENCHMARK_README.md.