summaryrefslogtreecommitdiff
diff options
from:
to:
context:
space:
mode:
authorGravatar Saya Andy <145215889+SayaAndy@users.noreply.github.com> 2025-09-06 21:35:54 +0700
committerGravatar GitHub <noreply@github.com> 2025-09-06 21:35:54 +0700
commit46a7e3ea25eb0d5b95a303018159cc59807a1367 (patch)
treec732d2774a4c6c515bf1d9ea46875a7a2c740063
parent4161e051f4437a4ab68430a4e542b76b1f335c3a (diff)
parentf219d4ac0e8d8f6f9dd7cd9be9e8038939863233 (diff)
downloadweb-0.8.1.tar.gz
web-0.8.1.zip
v0.8.1 (#8)v0.8.1
- fix: differentiate lang for blog search cache
-rw-r--r--internal/router/api-v1-blog-search.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/internal/router/api-v1-blog-search.go b/internal/router/api-v1-blog-search.go
index 41f2dec..946b830 100644
--- a/internal/router/api-v1-blog-search.go
+++ b/internal/router/api-v1-blog-search.go
@@ -36,8 +36,9 @@ func Api_V1_BlogSearch(l map[string]*locale.LocaleConfig, langs []string, b2Clie
slog.Warn("unable to parse a client timezone, defaulting to UTC", slog.String("error", err.Error()), slog.String("tz", tz))
}
+ cacheKey := "blog-search." + lang + ".pages-list"
var pages []*b2.BlogPage
- if pagesBytes, ok := PCache.Get("blog-search.pages-list"); pagesBytes != nil || ok {
+ if pagesBytes, ok := PCache.Get(cacheKey); pagesBytes != nil || ok {
json.Unmarshal(pagesBytes, &pages)
} else {
pages, err = b2Client.Scan(lang + "/")
@@ -46,7 +47,7 @@ func Api_V1_BlogSearch(l map[string]*locale.LocaleConfig, langs []string, b2Clie
return c.Status(fiber.ErrInternalServerError.Code).SendString(fmt.Sprintf("failed to scan pages for '%s' lang: %v", lang, err))
}
pagesBytes, _ := json.Marshal(pages)
- PCache.SetWithTTL("blog-search.pages-list", pagesBytes, int64(len(pagesBytes)), 5*time.Minute)
+ PCache.SetWithTTL(cacheKey, pagesBytes, int64(len(pagesBytes)), 5*time.Minute)
}
encodedQuery := c.Request().URI().QueryString()