Skip to content

Tutorial: Using HeliosDB's Redis Protocol

Tutorial: Using HeliosDB’s Redis Protocol

Level: Intermediate | Time: 15 minutes | Version: 7.2.0

HeliosDB implements 104+ Redis commands natively — no external Redis needed.

Start with Redis Enabled

Terminal window
heliosdb-full --enable-redis --redis-port 6379

Connect with redis-cli

Terminal window
redis-cli -p 6379

Core Operations

Terminal window
# String commands
SET hello "world"
GET hello
INCR counter
APPEND greeting " world"
# Hash commands
HSET user:1 name "Alice" age "30"
HGETALL user:1
# List commands (BullMQ-compatible queues)
LPUSH jobs "task1" "task2" "task3"
RPOP jobs
BLPOP jobs 5 # Blocking pop with 5s timeout
LMOVE jobs done LEFT RIGHT # Atomic reliable queue
# Set operations
SADD tags:post1 "rust" "database" "distributed"
SADD tags:post2 "rust" "performance"
SINTER tags:post1 tags:post2 # → "rust"
SUNION tags:post1 tags:post2
SDIFF tags:post1 tags:post2
# Sorted sets (leaderboards)
ZADD scores 100 "alice" 85 "bob" 92 "carol"
ZRANGEBYSCORE scores 90 +inf # → alice, carol
ZREVRANGE scores 0 2 WITHSCORES

Advanced Features

Streams (event sourcing)

Terminal window
XADD events '*' type "order" amount "99.50"
XADD events '*' type "payment" status "completed"
XLEN events
XRANGE events - +
XREAD COUNT 10 STREAMS events 0

Geospatial

Terminal window
GEOADD stores -73.9857 40.7484 "NYC" -118.2437 34.0522 "LA"
GEODIST stores NYC LA km
GEOSEARCH stores FROMMEMBER NYC BYRADIUS 500 km ASC

HyperLogLog (cardinality estimation)

Terminal window
PFADD visitors "user1" "user2" "user3" "user1"
PFCOUNT visitors # → 3 (unique)

Lua Scripting

Terminal window
EVAL "return redis.call('GET', KEYS[1])" 1 hello
EVAL "redis.call('SET', KEYS[1], ARGV[1]); return 1" 1 mykey myvalue

Pub/Sub

Terminal window
# Terminal 1: Subscribe
SUBSCRIBE notifications
# Terminal 2: Publish
PUBLISH notifications "Hello from HeliosDB!"

Sorting

Terminal window
LPUSH numbers 3 1 4 1 5 9 2 6
SORT numbers # → 1 1 2 3 4 5 6 9
SORT numbers DESC # → 9 6 5 4 3 2 1 1

ACL (Access Control)

Terminal window
ACL WHOAMI # → "default"
ACL LIST # → user permissions
ACL CAT # → command categories

Client Compatibility

HeliosDB’s Redis protocol supports:

  • redis-cli — Full compatibility
  • Sidekiq/BullMQ — CONFIG/CLIENT/COMMAND stubs prevent connect errors
  • Lettuce/Jedis — Java clients work via RESP2
  • ioredis — Node.js client compatible

Monitor Redis from SQL

-- From psql:
SHOW REDIS STATUS;
-- Returns: version, commands, features, auth, resp_version