git-pr

created pr with 56.1 on 2025-03-27T20:16:09Z · by c8ef7d19
added 56.2 on 2025-03-27T20:17:48Z · by c8ef7d19
1: 0200c93 ! 1: a2710a3 refactor: custom index page
added 56.3 on 2025-03-28T14:48:26Z · by c8ef7d19
1: a2710a3 < -: ------- refactor: custom index page
-: ------- > 1: 7338b44 feat: allow config `desc` to add a description box to index page
added 56.4 on 2025-04-06T19:08:12Z · by c8ef7d19
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 on 2025-04-06T22:13:51Z · by c8ef7d19
cmds
checkout latest patchset:
ssh pr.pico.sh print 56 | git am -3
checkout any patchset in a patch request:
ssh pr.pico.sh print 56.[rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 56
set PR to open (enables RSS notifications):
ssh pr.pico.sh pr open 56
set PR to draft (stops RSS notifications):
ssh pr.pico.sh pr draft 56
+12 -2 pkg/apps/pgs/web.go #
......@@ -75,7 +75,7 @@ func StartApiServer(cfg *PgsConfig) {
7575 routes: routes,
7676 }
7777
78- go routes.cacheMgmt(ctx, httpCache)
78+ go routes.cacheMgmt(ctx, httpCache, cfg.CacheClearingQueue)
7979
8080 portStr := fmt.Sprintf(":%s", cfg.WebPort)
8181 cfg.Logger.Info(
......@@ -260,7 +260,7 @@ func (web *WebRouter) checkHandler(w http.ResponseWriter, r *http.Request) {
260260 w.WriteHeader(http.StatusNotFound)
261261 }
262262
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) {
264264 storer := httpCache.Storers[0]
265265 drain := createSubCacheDrain(ctx, web.Cfg.Logger)
266266
......@@ -270,6 +270,7 @@ func (web *WebRouter) cacheMgmt(ctx context.Context, httpCache *middleware.Souin
270270 for scanner.Scan() {
271271 surrogateKey := strings.TrimSpace(scanner.Text())
272272 web.Cfg.Logger.Info("received cache-drain item", "surrogateKey", surrogateKey)
273+ notify <- surrogateKey
273274
274275 if surrogateKey == "*" {
275276 storer.DeleteMany(".+")
......@@ -509,6 +510,15 @@ func (web *WebRouter) ServeAsset(fname string, opts *storage.ImgProcessOpts, fro
509510 }
510511 }
511512
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+
512522 asset := &ApiAssetHandler{
513523 WebRouter: web,
514524 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) {
4949 logger := h.Logger
5050 var redirects []*RedirectRule
5151
52- redirectsCacheKey := filepath.Join(h.Bucket.Name, h.ProjectDir, "_redirects")
52+ redirectsCacheKey := filepath.Join(getSurrogateKey(h.UserID, h.ProjectDir), "_redirects")
5353 if cachedRedirects, found := redirectsCache.Get(redirectsCacheKey); found {
5454 redirects = cachedRedirects
5555 } else {
......@@ -179,7 +179,7 @@ func (h *ApiAssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
179179
180180 var headers []*HeaderRule
181181
182- headersCacheKey := filepath.Join(h.Bucket.Name, h.ProjectDir, "_headers")
182+ headersCacheKey := filepath.Join(getSurrogateKey(h.UserID, h.ProjectDir), "_headers")
183183 if cachedHeaders, found := headersCache.Get(headersCacheKey); found {
184184 headers = cachedHeaders
185185 } else {
Back to top