git-pr
created pr with
56.1
added 56.2
1: 0200c93 ! 1: a2710a3 refactor: custom index page
added 56.3
1: a2710a3 < -: ------- refactor: custom index page
-: ------- > 1: 7338b44 feat: allow config `desc` to add a description box to index page
added 56.4
1: 7338b44 < -: ------- feat: allow config `desc` to add a description box to index page
-: ------- > 1: 26daea4 feat(pgs): lru cache for object info and special files
-: ------- > 2: b004b64 chore(pgs): use http cache clear event to rm lru cache for special files
-: ------- > 3: 59f5618 refactor(pgs): store lru cache on web router
changed status to
accepted
cmds
checkout latest patchset:
ssh pr.pico.sh print 56 | git am -3checkout any patchset in a patch request:
ssh pr.pico.sh print 56.[rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 56set PR to open (enables RSS notifications):
ssh pr.pico.sh pr open 56set PR to draft (stops RSS notifications):
ssh pr.pico.sh pr draft 56
Patchset
56.4
chore(pgs): use http cache clear event to rm lru cache for special files
Eric Bower
2025-04-06T03:03:27ZSemantic diff summary
0 added,
4 modified,
1 signature changed,
0 removed
across 2 analyzed files
+12
-2
pkg/apps/pgs/web.go
#
| ... | ... | @@ -260,7 +260,7 @@ func (web *WebRouter) checkHandler(w http.ResponseWriter, r *http.Request) { | |
| 260 | 260 | w.WriteHeader(http.StatusNotFound) | |
| 261 | 261 | } | |
| 262 | 262 | ||
| 263 | - | func (web *WebRouter) cacheMgmt(ctx context.Context, httpCache *middleware.SouinBaseHandler) { | |
| 263 | + | func (web *WebRouter) cacheMgmt(ctx context.Context, httpCache *middleware.SouinBaseHandler, notify chan string) { | |
| 264 | 264 | storer := httpCache.Storers[0] | |
| 265 | 265 | drain := createSubCacheDrain(ctx, web.Cfg.Logger) | |
| 266 | 266 |
| ... | ... | @@ -270,6 +270,7 @@ func (web *WebRouter) cacheMgmt(ctx context.Context, httpCache *middleware.Souin | |
| 270 | 270 | for scanner.Scan() { | |
| 271 | 271 | surrogateKey := strings.TrimSpace(scanner.Text()) | |
| 272 | 272 | web.Cfg.Logger.Info("received cache-drain item", "surrogateKey", surrogateKey) | |
| 273 | + | notify <- surrogateKey | |
| 273 | 274 | ||
| 274 | 275 | if surrogateKey == "*" { | |
| 275 | 276 | storer.DeleteMany(".+") |
| ... | ... | @@ -509,6 +510,15 @@ func (web *WebRouter) ServeAsset(fname string, opts *storage.ImgProcessOpts, fro | |
| 509 | 510 | } | |
| 510 | 511 | } | |
| 511 | 512 | ||
| 513 | + | go func() { | |
| 514 | + | for key := range web.Cfg.CacheClearingQueue { | |
| 515 | + | rKey := filepath.Join(key, "_redirects") | |
| 516 | + | redirectsCache.Remove(rKey) | |
| 517 | + | hKey := filepath.Join(key, "_headers") | |
| 518 | + | headersCache.Remove(hKey) | |
| 519 | + | } | |
| 520 | + | }() | |
| 521 | + | ||
| 512 | 522 | asset := &ApiAssetHandler{ | |
| 513 | 523 | WebRouter: web, | |
| 514 | 524 | Logger: logger, |
+2
-2
pkg/apps/pgs/web_asset_handler.go
#
| ... | ... | @@ -49,7 +49,7 @@ func (h *ApiAssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
| 49 | 49 | logger := h.Logger | |
| 50 | 50 | var redirects []*RedirectRule | |
| 51 | 51 | ||
| 52 | - | redirectsCacheKey := filepath.Join(h.Bucket.Name, h.ProjectDir, "_redirects") | |
| 52 | + | redirectsCacheKey := filepath.Join(getSurrogateKey(h.UserID, h.ProjectDir), "_redirects") | |
| 53 | 53 | if cachedRedirects, found := redirectsCache.Get(redirectsCacheKey); found { | |
| 54 | 54 | redirects = cachedRedirects | |
| 55 | 55 | } else { |
| ... | ... | @@ -179,7 +179,7 @@ func (h *ApiAssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
| 179 | 179 | ||
| 180 | 180 | var headers []*HeaderRule | |
| 181 | 181 | ||
| 182 | - | headersCacheKey := filepath.Join(h.Bucket.Name, h.ProjectDir, "_headers") | |
| 182 | + | headersCacheKey := filepath.Join(getSurrogateKey(h.UserID, h.ProjectDir), "_headers") | |
| 183 | 183 | if cachedHeaders, found := headersCache.Get(headersCacheKey); found { | |
| 184 | 184 | headers = cachedHeaders | |
| 185 | 185 | } else { |