summaryrefslogtreecommitdiff
path: root/internal/cache/db.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cache/db.go')
-rw-r--r--internal/cache/db.go17
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,
})
}