Move redis config to CacheConfig struct, add cache prefixes & trace logging

This commit is contained in:
Moritz Marquardt 2024-03-29 23:15:08 +01:00
parent e1a22d5f4c
commit 46c8daacba
7 changed files with 45 additions and 30 deletions

View file

@ -78,24 +78,24 @@ func Serve(ctx *cli.Context) error {
dnsLookupCache := mcache.New()
var redisErr error = nil
createCache := func() cache.ICache {
if cfg.RedisURL != "" {
opts, err := redis.ParseURL(cfg.RedisURL)
createCache := func(name string) cache.ICache {
if cfg.Cache.RedisURL != "" {
opts, err := redis.ParseURL(cfg.Cache.RedisURL)
if err != nil {
redisErr = err
}
return cache.NewRedisCache(opts)
return cache.NewRedisCache(name, opts)
}
return cache.NewInMemoryCache()
}
// challengeCache stores the certificate challenges
challengeCache := createCache()
challengeCache := createCache("challenge")
// canonicalDomainCache stores canonical domains
canonicalDomainCache := createCache()
canonicalDomainCache := createCache("canonicalDomain")
// redirectsCache stores redirects in _redirects files
redirectsCache := createCache()
redirectsCache := createCache("redirects")
// clientResponseCache stores responses from the Gitea server
clientResponseCache := createCache()
clientResponseCache := createCache("clientResponse")
if redisErr != nil {
return redisErr
}