Files
goclaw/cmd/gateway_redis_noop.go
T
viettranx 0d3230b2bf feat(cache): add build-tag-gated Redis cache backend
Add optional Redis cache support via `go build -tags redis`, following
the same paired-stub pattern as OTel and Tailscale. The Cache[V] interface
is unchanged; Redis and in-memory implementations are injected at startup
without altering usage logic.

- Add RedisCache[V] implementation with JSON serialization, fail-open on errors
- Add gateway_redis.go / gateway_redis_noop.go paired wiring files
- Refactor GroupWriterCache and ContextFileInterceptor to accept injected caches
- Add GOCLAW_REDIS_DSN env var, docker-compose.redis.yml overlay
- Update Dockerfile and GitHub Actions with ENABLE_REDIS build arg
- Add Redis variant to CI matrix (5 variants: latest, otel, tsnet, redis, full)
2026-03-07 19:27:24 +07:00

31 lines
998 B
Go

//go:build !redis
package cmd
import (
"log/slog"
"github.com/nextlevelbuilder/goclaw/internal/cache"
"github.com/nextlevelbuilder/goclaw/internal/config"
"github.com/nextlevelbuilder/goclaw/internal/store"
)
// initRedisClient is a no-op when built without the "redis" tag.
// Build with `go build -tags redis` to enable Redis cache.
func initRedisClient(_ *config.Config) any { return nil }
// makeCaches returns in-memory cache instances when Redis is not compiled in.
func makeCaches(_ any) (
agentCtxCache cache.Cache[[]store.AgentContextFileData],
userCtxCache cache.Cache[[]store.AgentContextFileData],
groupWriterCache cache.Cache[[]store.GroupFileWriterData],
) {
slog.Info("cache backend: in-memory")
return cache.NewInMemoryCache[[]store.AgentContextFileData](),
cache.NewInMemoryCache[[]store.AgentContextFileData](),
cache.NewInMemoryCache[[]store.GroupFileWriterData]()
}
// shutdownRedis is a no-op when built without the "redis" tag.
func shutdownRedis(_ any) {}