docs/self-hosting/advanced/redis.mdx
LobeHub uses Redis as a high-performance cache and session storage service to optimize system performance and manage user authentication state.
<Callout type={'info'}> LobeHub uses the standard Redis protocol (via ioredis library), supporting any Redis protocol-compatible service, including official Redis, self-hosted Redis, and cloud provider Redis services (such as AWS ElastiCache, Alibaba Cloud Redis, etc.). </Callout>
Redis is used in LobeHub for the following scenarios:
As secondary storage for Better Auth, used to store user authentication sessions and token data. This enables:
Caches S3 presigned URLs to reduce S3 API calls and optimize file access performance.
Caches Agent configuration data to reduce database queries and improve response speed.
The Redis server connection URL. This is required to enable Redis functionality.
REDIS_URL=redis://localhost:6379
Supported URL formats:
redis://localhost:6379redis://username:password@localhost:6379redis://localhost:6379/0REDIS_PREFIXThe prefix for Redis keys, used to isolate LobeHub data in a shared Redis instance.
lobechatREDIS_PREFIX=my-lobechatREDIS_TLSWhether to enable TLS/SSL encrypted connection.
falseREDIS_TLS=true<Callout type={'tip'}> If you use Redis services from cloud providers, you usually need to enable TLS to ensure secure data transmission. </Callout>
REDIS_PASSWORDRedis authentication password (optional). Set this if your Redis server is configured with password authentication.
REDIS_USERNAMERedis authentication username (optional). Redis 6.0+ supports ACL user authentication. Set this if using username authentication.
REDIS_DATABASERedis database index (optional). Redis supports multiple databases (default 0-15), you can specify which database to use.
0REDIS_DATABASE=1
</Steps>
REDIS_URL=redis://localhost:6379
REDIS_PREFIX=lobechat-dev
REDIS_URL=redis://localhost:6379
REDIS_PASSWORD=your-strong-password
REDIS_PREFIX=lobechat
REDIS_TLS=true
REDIS_URL=redis://your-cluster.cache.amazonaws.com:6379
REDIS_TLS=true
REDIS_PREFIX=lobechat
<Callout type={'warning'}>
Redis is an optional service. If REDIS_URL is not configured, LobeHub will still function
normally, but will lose the caching and session management optimizations mentioned above.
</Callout>