Move to []byte for caching and make it compile

This commit is contained in:
Moritz Marquardt 2024-03-26 07:38:15 +01:00
parent 5b6eecc75f
commit c4181d1206
11 changed files with 63 additions and 43 deletions

View file

@ -31,7 +31,7 @@ func (o *Options) getRedirects(giteaClient *gitea.Client, redirectsCache cache.I
// Check for cached redirects
if cachedValue, ok := redirectsCache.Get(cacheKey); ok {
redirects := []Redirect{}
err := json.Unmarshal([]byte(cachedValue), redirects)
err := json.Unmarshal(cachedValue, redirects)
if err != nil {
log.Error().Err(err).Msgf("could not parse redirects for key %s", cacheKey)
// It's okay to continue, the array stays empty.
@ -68,7 +68,7 @@ func (o *Options) getRedirects(giteaClient *gitea.Client, redirectsCache cache.I
if err != nil {
log.Error().Err(err).Msgf("could not store redirects for key %s", cacheKey)
} else {
_ = redirectsCache.Set(cacheKey, string(redirectsJson), redirectsCacheTimeout)
_ = redirectsCache.Set(cacheKey, redirectsJson, redirectsCacheTimeout)
}
}
return redirects