Redis cache

From bidewio/better-openclaw · View interactive version

Redis cache is an AI agent skill from the GitHub repository bidewio/better-openclaw. Cache data, manage sessions, and use pub/sub messaging via the Redis server running at {{REDIS_HOST}}:{{REDIS_PORT}} in your Docker network.

How to use this skill

Skill file

Redis Cache Skill

Redis is available at {{REDIS_HOST}}:{{REDIS_PORT}} within the Docker network.

Caching

To cache a value, use the Redis CLI or HTTP API through the sandbox shell:

redis-cli -h {{REDIS_HOST}} -p {{REDIS_PORT}} -a $REDIS_PASSWORD SET mykey "myvalue" EX 3600
redis-cli -h {{REDIS_HOST}} -p {{REDIS_PORT}} -a $REDIS_PASSWORD GET mykey

Pub/Sub

Publish messages to channels for real-time communication between services.

# Publish a message to a channel
redis-cli -h {{REDIS_HOST}} -p {{REDIS_PORT}} -a $REDIS_PASSWORD PUBLISH openclaw:events '{"type":"task_complete","id":"abc123"}'

# Subscribe to a channel (in a separate process)
redis-cli -h {{REDIS_HOST}} -p {{REDIS_PORT}} -a $REDIS_PASSWORD SUBSCRIBE openclaw:events

Hash Operations

Store structured data efficiently using Redis hashes:

# Set multiple fields on a hash
redis-cli -h {{REDIS_HOST}} -p {{REDIS_PORT}} -a $REDIS_PASSWORD HSET openclaw:session:user1 name "Alice" role "admin" last_seen "$(date -Iseconds)"

# Get all fields from a hash
redis-cli -h {{REDIS_HOST}} -p {{REDIS_PORT}} -a $REDIS_PASSWORD HGETALL openclaw:session:user1

List-Based Queues

Use Redis lists as lightweight task queues:

# Push a task onto the queue
redis-cli -h {{REDIS_HOST}} -p {{REDIS_PORT}} -a $REDIS_PASSWORD LPUSH openclaw:queue:tasks '{"action":"process","file":"input.csv"}'

# Pop a task from the queue (blocking)
redis-cli -h {{REDIS_HOST}} -p {{REDIS_PORT}} -a $REDIS_PASSWORD BRPOP openclaw:queue:tasks 30

Key Patterns

Tips for AI Agents

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.