summaryrefslogtreecommitdiff
path: root/internal/cache
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cache')
-rw-r--r--internal/cache/cache.go6
-rw-r--r--internal/cache/db.go28
2 files changed, 34 insertions, 0 deletions
diff --git a/internal/cache/cache.go b/internal/cache/cache.go
index 8187ba419..2949d528a 100644
--- a/internal/cache/cache.go
+++ b/internal/cache/cache.go
@@ -57,6 +57,7 @@ func (c *Caches) Init() {
log.Infof(nil, "init: %p", c)
c.initAccount()
+ c.initAccountIDsFollowingTag()
c.initAccountNote()
c.initAccountSettings()
c.initAccountStats()
@@ -98,6 +99,7 @@ func (c *Caches) Init() {
c.initStatusFave()
c.initStatusFaveIDs()
c.initTag()
+ c.initTagIDsFollowedByAccount()
c.initThreadMute()
c.initToken()
c.initTombstone()
@@ -134,6 +136,7 @@ func (c *Caches) Stop() {
// significant overhead to all cache writes.
func (c *Caches) Sweep(threshold float64) {
c.DB.Account.Trim(threshold)
+ c.DB.AccountIDsFollowingTag.Trim(threshold)
c.DB.AccountNote.Trim(threshold)
c.DB.AccountSettings.Trim(threshold)
c.DB.AccountStats.Trim(threshold)
@@ -142,6 +145,8 @@ func (c *Caches) Sweep(threshold float64) {
c.DB.BlockIDs.Trim(threshold)
c.DB.BoostOfIDs.Trim(threshold)
c.DB.Client.Trim(threshold)
+ c.DB.Conversation.Trim(threshold)
+ c.DB.ConversationLastStatusIDs.Trim(threshold)
c.DB.Emoji.Trim(threshold)
c.DB.EmojiCategory.Trim(threshold)
c.DB.Filter.Trim(threshold)
@@ -171,6 +176,7 @@ func (c *Caches) Sweep(threshold float64) {
c.DB.StatusFave.Trim(threshold)
c.DB.StatusFaveIDs.Trim(threshold)
c.DB.Tag.Trim(threshold)
+ c.DB.TagIDsFollowedByAccount.Trim(threshold)
c.DB.ThreadMute.Trim(threshold)
c.DB.Token.Trim(threshold)
c.DB.Tombstone.Trim(threshold)
diff --git a/internal/cache/db.go b/internal/cache/db.go
index 16e1d286a..c1b87ef96 100644
--- a/internal/cache/db.go
+++ b/internal/cache/db.go
@@ -29,6 +29,9 @@ type DBCaches struct {
// Account provides access to the gtsmodel Account database cache.
Account StructCache[*gtsmodel.Account]
+ // AccountIDsFollowingTag caches account IDs following a given tag ID.
+ AccountIDsFollowingTag SliceCache[string]
+
// AccountNote provides access to the gtsmodel Note database cache.
AccountNote StructCache[*gtsmodel.AccountNote]
@@ -160,6 +163,9 @@ type DBCaches struct {
// Tag provides access to the gtsmodel Tag database cache.
Tag StructCache[*gtsmodel.Tag]
+ // TagIDsFollowedByAccount caches tag IDs followed by a given account ID.
+ TagIDsFollowedByAccount SliceCache[string]
+
// ThreadMute provides access to the gtsmodel ThreadMute database cache.
ThreadMute StructCache[*gtsmodel.ThreadMute]
@@ -234,6 +240,17 @@ func (c *Caches) initAccount() {
})
}
+func (c *Caches) initAccountIDsFollowingTag() {
+ // Calculate maximum cache size.
+ cap := calculateSliceCacheMax(
+ config.GetCacheAccountIDsFollowingTagMemRatio(),
+ )
+
+ log.Infof(nil, "cache size = %d", cap)
+
+ c.DB.AccountIDsFollowingTag.Init(0, cap)
+}
+
func (c *Caches) initAccountNote() {
// Calculate maximum cache size.
cap := calculateResultCacheMax(
@@ -1317,6 +1334,17 @@ func (c *Caches) initTag() {
})
}
+func (c *Caches) initTagIDsFollowedByAccount() {
+ // Calculate maximum cache size.
+ cap := calculateSliceCacheMax(
+ config.GetCacheTagIDsFollowedByAccountMemRatio(),
+ )
+
+ log.Infof(nil, "cache size = %d", cap)
+
+ c.DB.TagIDsFollowedByAccount.Init(0, cap)
+}
+
func (c *Caches) initThreadMute() {
cap := calculateResultCacheMax(
sizeofThreadMute(), // model in-mem size.