Official Redis cache addon for Keel — implements contracts.Cache via go-redis v9.
ss-keel-redis adds Redis cache support to a Keel project via go-redis v9.
It is the official addon for distributed caching in the Keel ecosystem and implements contracts.Cache from ss-keel-core.
keel add redisThe Keel CLI will:
- Add
github.com/slice-soft/ss-keel-redisas a dependency. - Create
cmd/setup_redis.goand inject initialization code intocmd/main.go. - Add a
REDIS_URLenvironment variable example to both.envand.env.example.
client, err := ssredis.New(ssredis.Config{
URL: config.GetEnvOrDefault("REDIS_URL", "redis://localhost:6379"),
Logger: app.Logger(),
})
if err != nil {
app.Logger().Error("failed to start redis: %v", err)
}
defer client.Close()The URL field uses the standard Redis URL format: redis://[:password@]host[:port][/db-number].
Pool defaults applied when not overridden:
| Parameter | Default |
|---|---|
MaxActiveConns |
10 |
MinIdleConns |
2 |
MaxIdleConns |
5 |
ConnMaxIdleTime |
5 min |
ConnMaxLifetime |
30 min |
Override via Config.Pool:
client, err := ssredis.New(ssredis.Config{
URL: config.GetEnvOrDefault("REDIS_URL", "redis://localhost:6379"),
Logger: app.Logger(),
Pool: ssredis.PoolConfig{
MaxActiveConns: 20,
MinIdleConns: 5,
ConnMaxLifetime: time.Hour,
},
})contracts.Cache covers the four core operations:
ctx := context.Background()
// Store a value with a TTL
err := client.Set(ctx, "user:123", []byte(`{"name":"Alice"}`), 5*time.Minute)
// Retrieve — returns nil, nil when the key does not exist
val, err := client.Get(ctx, "user:123")
// Remove a key
err = client.Delete(ctx, "user:123")
// Check existence without reading the value
exists, err := client.Exists(ctx, "user:123")A zero TTL in Set means no expiration.
Use RDB() to access the full go-redis client for pipelines, transactions, Lua scripts, and Pub/Sub:
pipe := client.RDB().Pipeline()
pipe.Incr(ctx, "counter")
pipe.Expire(ctx, "counter", time.Hour)
_, err := pipe.Exec(ctx)Register the Redis connection in the Keel health endpoint:
app.RegisterHealthChecker(ssredis.NewHealthChecker(client))This exposes the Redis status under GET /health:
{ "redis": "UP" }- CI runs on every pull request targeting
mainvia.github/workflows/ci.yml. - Releases are created automatically on merge to
mainvia.github/workflows/release.ymlusing Release Please.
- Use
REDIS_URLfor all environments; it keeps credentials out of code and plays well with secrets managers. - Accept
contracts.Cachein your services — not*ssredis.Client— so you can swap the implementation in tests. - Register
NewHealthCheckerso Keel's/healthendpoint always reflects real Redis connectivity.
See CONTRIBUTING.md for setup and repository-specific rules. The base workflow, commit conventions, and community standards live in ss-community.
| Document | |
|---|---|
| CONTRIBUTING.md | Workflow, commit conventions, and PR guidelines |
| GOVERNANCE.md | Decision-making, roles, and release process |
| CODE_OF_CONDUCT.md | Community standards |
| VERSIONING.md | SemVer policy and breaking changes |
| SECURITY.md | How to report vulnerabilities |
| MAINTAINERS.md | Active maintainers |
MIT License - see LICENSE for details.
- Website: keel-go.dev
- GitHub: github.com/slice-soft/ss-keel-redis
- Documentation: docs.keel-go.dev
Made by SliceSoft — Colombia 💙