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
heliosdb-full --enable-redis --redis-port 6379Connect with redis-cli
redis-cli -p 6379Core Operations
# String commandsSET hello "world"GET helloINCR counterAPPEND greeting " world"
# Hash commandsHSET user:1 name "Alice" age "30"HGETALL user:1
# List commands (BullMQ-compatible queues)LPUSH jobs "task1" "task2" "task3"RPOP jobsBLPOP jobs 5 # Blocking pop with 5s timeoutLMOVE jobs done LEFT RIGHT # Atomic reliable queue
# Set operationsSADD tags:post1 "rust" "database" "distributed"SADD tags:post2 "rust" "performance"SINTER tags:post1 tags:post2 # → "rust"SUNION tags:post1 tags:post2SDIFF tags:post1 tags:post2
# Sorted sets (leaderboards)ZADD scores 100 "alice" 85 "bob" 92 "carol"ZRANGEBYSCORE scores 90 +inf # → alice, carolZREVRANGE scores 0 2 WITHSCORESAdvanced Features
Streams (event sourcing)
XADD events '*' type "order" amount "99.50"XADD events '*' type "payment" status "completed"XLEN eventsXRANGE events - +XREAD COUNT 10 STREAMS events 0Geospatial
GEOADD stores -73.9857 40.7484 "NYC" -118.2437 34.0522 "LA"GEODIST stores NYC LA kmGEOSEARCH stores FROMMEMBER NYC BYRADIUS 500 km ASCHyperLogLog (cardinality estimation)
PFADD visitors "user1" "user2" "user3" "user1"PFCOUNT visitors # → 3 (unique)Lua Scripting
EVAL "return redis.call('GET', KEYS[1])" 1 helloEVAL "redis.call('SET', KEYS[1], ARGV[1]); return 1" 1 mykey myvaluePub/Sub
# Terminal 1: SubscribeSUBSCRIBE notifications
# Terminal 2: PublishPUBLISH notifications "Hello from HeliosDB!"Sorting
LPUSH numbers 3 1 4 1 5 9 2 6SORT numbers # → 1 1 2 3 4 5 6 9SORT numbers DESC # → 9 6 5 4 3 2 1 1ACL (Access Control)
ACL WHOAMI # → "default"ACL LIST # → user permissionsACL CAT # → command categoriesClient 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