summaryrefslogtreecommitdiff
path: root/internal/cache/gts.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cache/gts.go')
-rw-r--r--internal/cache/gts.go26
1 files changed, 24 insertions, 2 deletions
diff --git a/internal/cache/gts.go b/internal/cache/gts.go
index 8082a9fdf..81c6e9f9e 100644
--- a/internal/cache/gts.go
+++ b/internal/cache/gts.go
@@ -26,8 +26,9 @@ import (
)
type GTSCaches struct {
- account *result.Cache[*gtsmodel.Account]
- block *result.Cache[*gtsmodel.Block]
+ account *result.Cache[*gtsmodel.Account]
+ accountNote *result.Cache[*gtsmodel.AccountNote]
+ block *result.Cache[*gtsmodel.Block]
// TODO: maybe should be moved out of here since it's
// not actually doing anything with gtsmodel.DomainBlock.
domainBlock *domain.BlockCache
@@ -54,6 +55,7 @@ type GTSCaches struct {
// NOTE: the cache MUST NOT be in use anywhere, this is not thread-safe.
func (c *GTSCaches) Init() {
c.initAccount()
+ c.initAccountNote()
c.initBlock()
c.initDomainBlock()
c.initEmoji()
@@ -77,6 +79,7 @@ func (c *GTSCaches) Init() {
// Start will attempt to start all of the gtsmodel caches, or panic.
func (c *GTSCaches) Start() {
tryStart(c.account, config.GetCacheGTSAccountSweepFreq())
+ tryStart(c.accountNote, config.GetCacheGTSAccountNoteSweepFreq())
tryStart(c.block, config.GetCacheGTSBlockSweepFreq())
tryStart(c.emoji, config.GetCacheGTSEmojiSweepFreq())
tryStart(c.emojiCategory, config.GetCacheGTSEmojiCategorySweepFreq())
@@ -104,6 +107,7 @@ func (c *GTSCaches) Start() {
// Stop will attempt to stop all of the gtsmodel caches, or panic.
func (c *GTSCaches) Stop() {
tryStop(c.account, config.GetCacheGTSAccountSweepFreq())
+ tryStop(c.accountNote, config.GetCacheGTSAccountNoteSweepFreq())
tryStop(c.block, config.GetCacheGTSBlockSweepFreq())
tryStop(c.emoji, config.GetCacheGTSEmojiSweepFreq())
tryStop(c.emojiCategory, config.GetCacheGTSEmojiCategorySweepFreq())
@@ -128,6 +132,11 @@ func (c *GTSCaches) Account() *result.Cache[*gtsmodel.Account] {
return c.account
}
+// AccountNote provides access to the gtsmodel Note database cache.
+func (c *GTSCaches) AccountNote() *result.Cache[*gtsmodel.AccountNote] {
+ return c.accountNote
+}
+
// Block provides access to the gtsmodel Block (account) database cache.
func (c *GTSCaches) Block() *result.Cache[*gtsmodel.Block] {
return c.block
@@ -238,6 +247,19 @@ func (c *GTSCaches) initAccount() {
c.account.IgnoreErrors(ignoreErrors)
}
+func (c *GTSCaches) initAccountNote() {
+ c.accountNote = result.New([]result.Lookup{
+ {Name: "ID"},
+ {Name: "AccountID.TargetAccountID"},
+ }, func(n1 *gtsmodel.AccountNote) *gtsmodel.AccountNote {
+ n2 := new(gtsmodel.AccountNote)
+ *n2 = *n1
+ return n2
+ }, config.GetCacheGTSAccountNoteMaxSize())
+ c.accountNote.SetTTL(config.GetCacheGTSAccountNoteTTL(), true)
+ c.accountNote.IgnoreErrors(ignoreErrors)
+}
+
func (c *GTSCaches) initBlock() {
c.block = result.New([]result.Lookup{
{Name: "ID"},