Getting Started
Welcome to DBX! This guide will help you get up and running with DBX in minutes.
Prerequisites
- Redis Server: A running Redis instance (version 6.0 or higher)
- Docker: For containerized deployment (optional)
- Node.js: For TypeScript SDK (version 16 or higher)
Quick Start with Docker
The fastest way to get started is using Docker:
# Run DBX with Redis
docker run -d --name dbx -p 3000:3000 \
-e REDIS_URL=redis://localhost:6379 \
effortlesslabs/0dbx_redis:latest
# Or use the convenience script
./scripts/run.sh --redis-url redis://localhost:6379
Installation Options
Docker (Recommended)
# Pull the latest image
docker pull effortlesslabs/0dbx_redis:latest
# Run with custom configuration
docker run -d --name dbx -p 8080:3000 \
-e REDIS_URL=redis://user:pass@redis.com:6379 \
-e PORT=3000 \
-e LOG_LEVEL=DEBUG \
effortlesslabs/0dbx_redis:latest
Binary Installation
# Download the latest release
curl -L https://github.com/effortlesslabs/dbx/releases/latest/download/dbx-x86_64-unknown-linux-gnu.tar.gz | tar xz
# Make executable
chmod +x dbx
# Run
./dbx --redis-url redis://localhost:6379
From Source
# Clone the repository
git clone https://github.com/effortlesslabs/dbx.git
cd dbx
# Build from source
cargo build --release
# Run
cargo run --bin dbx-redis-api -- --redis-url redis://localhost:6379
TypeScript SDK Setup
Install the TypeScript SDK:
npm install @0dbx/redis
# or
yarn add @0dbx/redis
# or
pnpm add @0dbx/redis
Your First API Call
Using the TypeScript SDK
import { DbxRedisClient } from "@0dbx/redis";
// Create client
const client = new DbxRedisClient("http://localhost:3000");
// String operations
await client.string.set("my-key", "hello world", 3600); // with TTL
const value = await client.string.get("my-key");
console.log(value); // "hello world"
// Set operations
await client.set.addMember("tags", "redis");
const members = await client.set.getMembers("tags");
// WebSocket client
import { DbxWsClient } from "@0dbx/redis";
const wsClient = new DbxWsClient("ws://localhost:3000/redis_ws");
await wsClient.string.set("my-key", "hello world");
Using cURL
# String operations
curl -X POST "http://localhost:3000/redis/string/my-key" \
-H "Content-Type: application/json" \
-d '{"value": "hello world", "ttl": 3600}'
curl "http://localhost:3000/redis/string/my-key"
# Response: "hello world"
# Set operations
curl -X POST "http://localhost:3000/redis/set/tags/members" \
-H "Content-Type: application/json" \
-d '{"members": ["redis", "database"]}'
curl "http://localhost:3000/redis/set/tags/members"
# Response: ["redis", "database"]
# Health check
curl "http://localhost:3000/redis/admin/health"
# Response: {"status": "ok"}
Using WebSocket
import { DbxWsClient } from "@0dbx/redis";
const wsClient = new DbxWsClient("ws://localhost:3000/redis_ws");
// Connect
await wsClient.connect();
// String operations
await wsClient.string.set("my-key", "hello world");
const value = await wsClient.string.get("my-key");
// Listen for real-time updates
wsClient.on("message", (data) => {
console.log("WebSocket message:", data);
});
Configuration
Environment Variables
Variable | Default | Description |
---|---|---|
REDIS_URL | redis://localhost:6379 | Redis connection URL |
PORT | 3000 | Server port |
HOST | 0.0.0.0 | Server host |
LOG_LEVEL | INFO | Logging level (DEBUG, INFO, WARN, ERROR) |
POOL_SIZE | 10 | Connection pool size |
Docker Environment Variables
When running with Docker, you can pass environment variables:
docker run -d --name dbx -p 3000:3000 \
-e REDIS_URL=redis://localhost:6379 \
-e HOST=0.0.0.0 \
-e PORT=3000 \
-e POOL_SIZE=10 \
-e LOG_LEVEL=INFO \
effortlesslabs/0dbx_redis:latest
Next Steps
- API Reference: Explore the complete REST API and WebSocket API documentation
- SDK Documentation: Learn more about the TypeScript SDK for seamless integration
- Deployment: Deploy to production with Docker or cloud platforms
- Examples: Check out various use cases and examples for edge computing
Troubleshooting
Common Issues
Connection refused# Check if Redis is running
redis-cli ping
# Should return: PONG
# Check what's using port 3000
lsof -i :3000
# Use a different port
docker run -d --name dbx -p 8080:3000 \
-e REDIS_URL=redis://localhost:6379 \
effortlesslabs/0dbx_redis:latest
# Check Redis URL format
# Should be: redis://[username:password@]host:port[/database]
# Test Redis connection
redis-cli -u redis://localhost:6379 ping
API Endpoints
REST API
GET /redis/string/{key}
- Get string valuePOST /redis/string/{key}
- Set string valueDELETE /redis/string/{key}
- Delete string valueGET /redis/hash/{key}/field/{field}
- Get hash fieldPOST /redis/hash/{key}/field/{field}
- Set hash fieldGET /redis/set/{key}/members
- Get set membersPOST /redis/set/{key}/members
- Add set membersGET /redis/admin/health
- Health checkGET /redis/admin/ping
- Ping server
WebSocket API
ws://localhost:3000/redis_ws/string/ws
- String operationsws://localhost:3000/redis_ws/hash/ws
- Hash operationsws://localhost:3000/redis_ws/set/ws
- Set operationsws://localhost:3000/redis_ws/admin/ws
- Admin operations