mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-05-14 17:27:10 +02:00
Make it possible to actually use redis for caching through the config flags
This commit is contained in:
parent
c4181d1206
commit
e1a22d5f4c
5 changed files with 37 additions and 12 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/OrlovEvgeny/go-mcache"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
|
@ -71,16 +72,33 @@ func Serve(ctx *cli.Context) error {
|
|||
}
|
||||
defer closeFn()
|
||||
|
||||
// keyCache stores the parsed certificate objects (Redis is no advantage here)
|
||||
keyCache := mcache.New()
|
||||
challengeCache := cache.NewInMemoryCache()
|
||||
// canonicalDomainCache stores canonical domains
|
||||
canonicalDomainCache := cache.NewInMemoryCache()
|
||||
// dnsLookupCache stores DNS lookups for custom domains
|
||||
// dnsLookupCache stores DNS lookups for custom domains (Redis is no advantage here)
|
||||
dnsLookupCache := mcache.New()
|
||||
|
||||
var redisErr error = nil
|
||||
createCache := func() cache.ICache {
|
||||
if cfg.RedisURL != "" {
|
||||
opts, err := redis.ParseURL(cfg.RedisURL)
|
||||
if err != nil {
|
||||
redisErr = err
|
||||
}
|
||||
return cache.NewRedisCache(opts)
|
||||
}
|
||||
return cache.NewInMemoryCache()
|
||||
}
|
||||
// challengeCache stores the certificate challenges
|
||||
challengeCache := createCache()
|
||||
// canonicalDomainCache stores canonical domains
|
||||
canonicalDomainCache := createCache()
|
||||
// redirectsCache stores redirects in _redirects files
|
||||
redirectsCache := cache.NewInMemoryCache()
|
||||
redirectsCache := createCache()
|
||||
// clientResponseCache stores responses from the Gitea server
|
||||
clientResponseCache := cache.NewInMemoryCache()
|
||||
clientResponseCache := createCache()
|
||||
if redisErr != nil {
|
||||
return redisErr
|
||||
}
|
||||
|
||||
giteaClient, err := gitea.NewClient(cfg.Gitea, clientResponseCache)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue