diff options
author | 2024-09-23 11:53:42 +0000 | |
---|---|---|
committer | 2024-09-23 11:53:42 +0000 | |
commit | 4592e290872e0208d03189aea4f410cd47a5dc1d (patch) | |
tree | 00df4221fc924e8fdcafc985f33c0395687a711c /internal/cache/db.go | |
parent | [chore] header filter improvements (#3329) (diff) | |
download | gotosocial-4592e290872e0208d03189aea4f410cd47a5dc1d.tar.xz |
[chore] local instance count query caching, improved status context endpoint logging, don't log ErrHideStatus when timelining (#3330)
* ensure that errors checking status visibility / converting aren't dropped
* add some more context to error messages
* include calling function name in log entries
* don't error on timelining hidden status
* further code to ignore statusfilter.ErrHideStatus type errors
* remove unused error type
* add local instance status / domain / user counts
* add checks for localhost
* rename from InstanceCounts to LocalInstance
* improved code comment
Diffstat (limited to 'internal/cache/db.go')
-rw-r--r-- | internal/cache/db.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/internal/cache/db.go b/internal/cache/db.go index fe9085613..dd4e8b212 100644 --- a/internal/cache/db.go +++ b/internal/cache/db.go @@ -18,6 +18,8 @@ package cache import ( + "sync/atomic" + "codeberg.org/gruf/go-structr" "github.com/superseriousbusiness/gotosocial/internal/cache/domain" "github.com/superseriousbusiness/gotosocial/internal/config" @@ -136,6 +138,14 @@ type DBCaches struct { // Instance provides access to the gtsmodel Instance database cache. Instance StructCache[*gtsmodel.Instance] + // LocalInstance provides caching for + // simple + common local instance queries. + LocalInstance struct { + Domains atomic.Pointer[int] + Statuses atomic.Pointer[int] + Users atomic.Pointer[int] + } + // InteractionRequest provides access to the gtsmodel InteractionRequest database cache. InteractionRequest StructCache[*gtsmodel.InteractionRequest] @@ -849,9 +859,10 @@ func (c *Caches) initInstance() { {Fields: "ID"}, {Fields: "Domain"}, }, - MaxSize: cap, - IgnoreErr: ignoreErrors, - Copy: copyF, + MaxSize: cap, + IgnoreErr: ignoreErrors, + Copy: copyF, + Invalidate: c.OnInvalidateInstance, }) } |