Skip to main content

Databases & Caching

Production-ready databases and caching solutions for structured data, NoSQL, graph relationships, and high-performance in-memory storage.

Available Services

PostgreSQL

Port: 5432 | Memory: 256 MB | Maturity: StablePowerful open-source relational database for structured data, supporting advanced SQL features, JSONB, and full-text search.Features:
  • ACID compliance
  • Advanced SQL support
  • JSONB document storage
  • Full-text search
  • Foreign keys and constraints
  • Mature ecosystem
OpenClaw Integration:
  • Environment: POSTGRES_HOST, POSTGRES_PORT
Version: 17-alpineDocumentation

Redis

Port: 6379 | Memory: 128 MB | Maturity: StableIn-memory data store for caching, session management, pub/sub messaging, and high-performance key-value operations.Features:
  • In-memory speed
  • Pub/sub messaging
  • Sorted sets and lists
  • Persistence options
  • Lua scripting
  • Cluster support
OpenClaw Integration:
  • Skill: redis-cache
  • Environment: REDIS_HOST, REDIS_PORT, REDIS_PASSWORD
Native Support: Linux (apt/dnf + systemd)Conflicts With: ValkeyDocumentation

Convex

Port: 3210 (API), 3211 (HTTP) | Memory: 256 MB | Maturity: StableSelf-hosted Convex reactive backend. Real-time database, server functions, and file storage in a single service.Features:
  • Real-time reactivity
  • Server functions
  • File storage
  • TypeScript support
  • SQLite or PostgreSQL
  • Mission Control required
Recommends: Convex DashboardDocumentation

Neo4j

Port: 7474 (HTTP), 7687 (Bolt) | Memory: 512 MB | Maturity: StableGraph database platform for connected data, enabling knowledge graphs, fraud detection, and relationship-driven queries with Cypher.Features:
  • Native graph storage
  • Cypher query language
  • ACID transactions
  • Index-free adjacency
  • Graph algorithms
  • Visual browser
OpenClaw Integration:
  • Environment: NEO4J_HOST, NEO4J_BOLT_PORT, NEO4J_HTTP_PORT
Documentation

Supabase

Port: 3000 (Studio), 8000 (API) | Memory: 2048 MB | Maturity: StableThe open source Firebase alternative. Build production-grade backends instantly with database, auth, storage, and edge functions.Features:
  • PostgreSQL database
  • Authentication
  • Real-time subscriptions
  • Storage
  • Edge functions
  • Studio dashboard
Requires: PostgreSQLDocumentation

Valkey

Port: 6380 | Memory: 128 MB | Maturity: StableOpen-source, high-performance key-value store and Redis-compatible fork maintained by the Linux Foundation.Features:
  • Redis compatibility
  • Linux Foundation backed
  • In-memory speed
  • Pub/sub messaging
  • Persistence
  • Open governance
OpenClaw Integration:
  • Environment: REDIS_HOST, REDIS_PORT (Redis-compatible)
Conflicts With: RedisDocumentation

Usage Examples

Full Stack Database Setup

npx create-better-openclaw \
  --services postgresql,redis,neo4j \
  --yes

Minimal Cache + Database

npx create-better-openclaw --preset minimal --yes
This includes: Redis only

Backend Platform

npx create-better-openclaw \
  --services supabase,postgresql,redis \
  --yes

Database Comparison

DatabaseTypeUse CaseACIDMemoryMaturity
PostgreSQLSQLStructured data, complex queries256 MBStable
RedisKey-ValueCaching, sessions, pub/sub⚠️128 MBStable
ConvexReal-timeReactive apps, server functions256 MBStable
Neo4jGraphRelationships, knowledge graphs512 MBStable
SupabasePlatformFull backend, auth, storage2048 MBStable
ValkeyKey-ValueRedis alternative, caching⚠️128 MBStable

Architecture Patterns

Layered Caching

# Redis for hot data
# PostgreSQL for persistent storage
npx create-better-openclaw --services redis,postgresql --yes

Graph + Relational Hybrid

# Neo4j for relationships
# PostgreSQL for tabular data
npx create-better-openclaw --services neo4j,postgresql --yes

Real-Time Backend

# Convex for reactive data
# Redis for caching
npx create-better-openclaw --services convex,redis --yes

Performance Optimization

PostgreSQL

  1. Indexes: Create indexes on frequently queried columns
  2. Connection Pooling: Use PgBouncer for connection management
  3. Partitioning: Partition large tables by date or key
  4. JSONB: Use JSONB for semi-structured data
  5. Vacuum: Configure autovacuum appropriately

Redis

  1. Memory Management: Set maxmemory and eviction policies
  2. Persistence: Choose RDB or AOF based on needs
  3. Key Naming: Use consistent key naming conventions
  4. Expiration: Set TTLs on cached data
  5. Pipeline: Use pipelining for bulk operations

Neo4j

  1. Indexes: Create indexes on frequently queried properties
  2. Constraints: Use constraints for data integrity
  3. Query Optimization: Use EXPLAIN for query analysis
  4. Batch Imports: Use LOAD CSV or batch APIs
  5. Memory Configuration: Tune heap and page cache

Data Persistence

Volumes

All databases use Docker volumes for persistence:
volumes:
  postgres-data:      # PostgreSQL data
  redis-data:         # Redis snapshots
  neo4j-data:         # Neo4j graph data
  convex-data:        # Convex SQLite/data
  supabase_db:        # Supabase storage

Backup Strategies

PostgreSQL Backups

# Backup
docker exec postgresql pg_dump -U openclaw openclaw > backup.sql

# Restore
cat backup.sql | docker exec -i postgresql psql -U openclaw openclaw

Redis Backups

# Trigger save
docker exec redis redis-cli SAVE

# Copy RDB file
docker cp redis:/data/dump.rdb ./redis-backup.rdb

Neo4j Backups

# Export to Cypher
docker exec neo4j neo4j-admin database dump neo4j --to-path=/data

Security Best Practices

Authentication

  1. Strong Passwords: Generate random passwords for production
  2. Environment Variables: Store credentials in .env
  3. Network Isolation: Use Docker networks
  4. Connection Limits: Configure max connections
  5. SSL/TLS: Enable encrypted connections in production

Access Control

  1. User Roles: Create separate users with minimal permissions
  2. Database Isolation: Use separate databases per service
  3. Network Policies: Restrict database ports to internal network
  4. Audit Logs: Enable logging for security events
  5. Regular Updates: Keep database images updated

Integration Patterns

Application Stack

npx create-better-openclaw \
  --services postgresql,redis,n8n,grafana \
  --yes

AI + Database

npx create-better-openclaw \
  --services postgresql,redis,qdrant,ollama \
  --yes

Full Platform

npx create-better-openclaw \
  --services supabase,postgresql,redis,neo4j \
  --yes

Monitoring

Monitor database health with:
  • Grafana + Prometheus: Metrics dashboards
  • Health Checks: Built-in Docker health checks
  • Logs: Access via docker logs
  • Query Performance: Enable slow query logs
# View PostgreSQL logs
docker logs postgresql -f

# View Redis stats
docker exec redis redis-cli INFO

# Check Neo4j status
docker exec neo4j cypher-shell "CALL dbms.listConfig();"

Build docs developers (and LLMs) love