summaryrefslogtreecommitdiff
path: root/internal/cache
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cache')
-rw-r--r--internal/cache/cache.go1
-rw-r--r--internal/cache/db.go15
-rw-r--r--internal/cache/invalidate.go7
3 files changed, 23 insertions, 0 deletions
diff --git a/internal/cache/cache.go b/internal/cache/cache.go
index 2cc07de96..5bfa70ffa 100644
--- a/internal/cache/cache.go
+++ b/internal/cache/cache.go
@@ -96,6 +96,7 @@ func (c *Caches) Init() {
c.initFollowRequest()
c.initFollowRequestIDs()
c.initFollowingTagIDs()
+ c.initHomeAccountIDs()
c.initHomeTimelines()
c.initInReplyToIDs()
c.initInstance()
diff --git a/internal/cache/db.go b/internal/cache/db.go
index 8a8f59539..d5f25516b 100644
--- a/internal/cache/db.go
+++ b/internal/cache/db.go
@@ -145,6 +145,10 @@ type DBCaches struct {
//
FollowingTagIDs SliceCache[string]
+ // HomeAccountIDs provides access to the account IDs present in an account's
+ // home timeline, bearing in mind that some may be part of exclusive lists.
+ HomeAccountIDs SliceCache[string]
+
// Instance provides access to the gtsmodel Instance database cache.
Instance StructCache[*gtsmodel.Instance]
@@ -883,6 +887,17 @@ func (c *Caches) initFollowingTagIDs() {
c.DB.FollowingTagIDs.Init(0, cap)
}
+func (c *Caches) initHomeAccountIDs() {
+ // Calculate maximum cache size.
+ cap := calculateSliceCacheMax(
+ config.GetCacheHomeAccountIDsMemRatio(),
+ )
+
+ log.Infof(nil, "cache size = %d", cap)
+
+ c.DB.HomeAccountIDs.Init(0, cap)
+}
+
func (c *Caches) initInReplyToIDs() {
// Calculate maximum cache size.
cap := calculateSliceCacheMax(
diff --git a/internal/cache/invalidate.go b/internal/cache/invalidate.go
index c6c25d4eb..58c427050 100644
--- a/internal/cache/invalidate.go
+++ b/internal/cache/invalidate.go
@@ -155,6 +155,9 @@ func (c *Caches) OnInvalidateFollow(follow *gtsmodel.Follow) {
// results for them as mute / visibility result requester.
if follow.Account == nil || follow.Account.IsLocal() {
localAccountIDs = append(localAccountIDs, follow.AccountID)
+
+ // Also invalidate their home account IDs cache.
+ c.DB.HomeAccountIDs.Invalidate(follow.AccountID)
}
// If target is local (or uncertain), also invalidate
@@ -261,6 +264,10 @@ func (c *Caches) OnInvalidateList(list *gtsmodel.List) {
// follow IDs in list.
"f"+list.ID,
)
+
+ // Invalidate user's home account IDs cache,
+ // as list exclusivity flag may have changed.
+ c.DB.HomeAccountIDs.Invalidate(list.AccountID)
}
func (c *Caches) OnInvalidateMedia(media *gtsmodel.MediaAttachment) {