diff options
author | 2023-07-31 11:25:29 +0100 | |
---|---|---|
committer | 2023-07-31 11:25:29 +0100 | |
commit | ed2477ebea4c3ceec5949821f4950db9669a4a15 (patch) | |
tree | 1038d7abdfc787ddfc1febb326fd38775b189b85 /internal/cache/util.go | |
parent | [bugfix/frontend] Decode URI component domain before showing on frontend (#2043) (diff) | |
download | gotosocial-ed2477ebea4c3ceec5949821f4950db9669a4a15.tar.xz |
[performance] cache follow, follow request and block ID lists (#2027)
Diffstat (limited to 'internal/cache/util.go')
-rw-r--r-- | internal/cache/util.go | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/internal/cache/util.go b/internal/cache/util.go index a0adfd366..f2357c904 100644 --- a/internal/cache/util.go +++ b/internal/cache/util.go @@ -18,28 +18,33 @@ package cache import ( - "context" + "database/sql" "errors" "fmt" "time" "codeberg.org/gruf/go-cache/v3/result" errorsv2 "codeberg.org/gruf/go-errors/v2" + "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/log" ) -// SentinelError is returned to indicate a non-permanent error return, -// i.e. a situation in which we do not want a cache a negative result. +// SentinelError is an error that can be returned and checked against to indicate a non-permanent +// error return from a cache loader callback, e.g. a temporary situation that will soon be fixed. var SentinelError = errors.New("BUG: error should not be returned") //nolint:revive -// ignoreErrors is an error ignoring function capable of being passed to -// caches, which specifically catches and ignores our sentinel error type. +// ignoreErrors is an error matching function used to signal which errors +// the result caches should NOT hold onto. these amount to anything non-permanent. func ignoreErrors(err error) bool { - return errorsv2.Comparable( + return !errorsv2.Comparable( err, - SentinelError, - context.DeadlineExceeded, - context.Canceled, + + // the only cacheable errs, + // i.e anything permanent + // (until invalidation). + db.ErrNoEntries, + db.ErrAlreadyExists, + sql.ErrNoRows, ) } |