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.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/cache/db.go b/internal/cache/db.go
index 894d74109..275a25451 100644
--- a/internal/cache/db.go
+++ b/internal/cache/db.go
@@ -36,6 +36,13 @@ type GTSCaches struct {
// AccountNote provides access to the gtsmodel Note database cache.
AccountNote structr.Cache[*gtsmodel.AccountNote]
+ // TEMPORARY CACHE TO ALLEVIATE SLOW COUNT QUERIES,
+ // (in time will be removed when these IDs are cached).
+ AccountCounts *simple.Cache[string, struct {
+ Statuses int
+ Pinned int
+ }]
+
// Application provides access to the gtsmodel Application database cache.
Application structr.Cache[*gtsmodel.Application]
@@ -192,6 +199,22 @@ func (c *Caches) initAccount() {
})
}
+func (c *Caches) initAccountCounts() {
+ // Simply use size of accounts cache,
+ // as this cache will be very small.
+ cap := c.GTS.Account.Cap()
+ if cap == 0 {
+ panic("must be initialized before accounts")
+ }
+
+ log.Infof(nil, "cache size = %d", cap)
+
+ c.GTS.AccountCounts = simple.New[string, struct {
+ Statuses int
+ Pinned int
+ }](0, cap)
+}
+
func (c *Caches) initAccountNote() {
// Calculate maximum cache size.
cap := calculateResultCacheMax(