Skip to content

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

VariableDefaultDescription
REDIS_URLredis://localhost:6379Redis connection URL
PORT3000Server port
HOST0.0.0.0Server host
LOG_LEVELINFOLogging level (DEBUG, INFO, WARN, ERROR)
POOL_SIZE10Connection 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
Port already in use
# 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
Redis connection failed
# 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 value
  • POST /redis/string/{key} - Set string value
  • DELETE /redis/string/{key} - Delete string value
  • GET /redis/hash/{key}/field/{field} - Get hash field
  • POST /redis/hash/{key}/field/{field} - Set hash field
  • GET /redis/set/{key}/members - Get set members
  • POST /redis/set/{key}/members - Add set members
  • GET /redis/admin/health - Health check
  • GET /redis/admin/ping - Ping server

WebSocket API

  • ws://localhost:3000/redis_ws/string/ws - String operations
  • ws://localhost:3000/redis_ws/hash/ws - Hash operations
  • ws://localhost:3000/redis_ws/set/ws - Set operations
  • ws://localhost:3000/redis_ws/admin/ws - Admin operations