Skip to content

Commit f72c037

Browse files
feat: invalidate cache should be immediately. (#28)
1 parent 62fb39f commit f72c037

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

caching_handler.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,12 @@ func (c *Caching) handleMutationRequest(w http.ResponseWriter, r *cachingRequest
228228
}
229229

230230
if c.DebugHeaders {
231-
w.Header().Set("x-debug-purging-tags", strings.Join(purgeTags, "; "))
231+
w.Header().Set("x-debug-purged-tags", strings.Join(purgeTags, "; "))
232232
}
233233

234-
go func() {
235-
if err := c.purgeQueryResultByTags(c.ctxBackground, purgeTags); err != nil {
236-
c.logger.Info("fail to purge query result by tags", zap.Error(err))
237-
}
238-
}()
234+
if err = c.purgeQueryResultByTags(c.ctxBackground, purgeTags); err != nil {
235+
c.logger.Error("fail to purge query result by tags", zap.Error(err))
236+
}
239237

240238
return err
241239
}

handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ caching {
492492
actualHitTimes := resp.Header.Get("x-cache-hits")
493493
actualStatus := resp.Header.Get("x-cache")
494494
actualCachingTags := resp.Header.Get("x-debug-result-tags")
495-
actualPurgingTags := resp.Header.Get("x-debug-purging-tags")
495+
actualPurgingTags := resp.Header.Get("x-debug-purged-tags")
496496

497497
s.Require().Equalf(testCase.expectedBody, string(respBody), "case %s: unexpected payload", testCase.name)
498498
s.Require().Equalf(string(testCase.expectedCachingStatus), actualStatus, "case %s: unexpected status", testCase.name)

0 commit comments

Comments
 (0)