Skip to content

Commit

Permalink
feat: invalidate cache should be immediately.
Browse files Browse the repository at this point in the history
  • Loading branch information
vuongxuongminh committed May 4, 2022
1 parent 62fb39f commit 6cb3d6c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions caching_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,12 @@ func (c *Caching) handleMutationRequest(w http.ResponseWriter, r *cachingRequest
}

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

go func() {
if err := c.purgeQueryResultByTags(c.ctxBackground, purgeTags); err != nil {
c.logger.Info("fail to purge query result by tags", zap.Error(err))
}
}()
if err = c.purgeQueryResultByTags(c.ctxBackground, purgeTags); err != nil {
c.logger.Error("fail to purge query result by tags", zap.Error(err))
}

return err
}
2 changes: 1 addition & 1 deletion handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ caching {
actualHitTimes := resp.Header.Get("x-cache-hits")
actualStatus := resp.Header.Get("x-cache")
actualCachingTags := resp.Header.Get("x-debug-result-tags")
actualPurgingTags := resp.Header.Get("x-debug-purging-tags")
actualPurgingTags := resp.Header.Get("x-debug-purged-tags")

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

0 comments on commit 6cb3d6c

Please sign in to comment.