diff options
Diffstat (limited to 'internal/cache')
-rw-r--r-- | internal/cache/gts.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/cache/gts.go b/internal/cache/gts.go index f3f7a33ef..253dc47b2 100644 --- a/internal/cache/gts.go +++ b/internal/cache/gts.go @@ -54,6 +54,9 @@ type GTSCaches interface { // Mention provides access to the gtsmodel Mention database cache. Mention() *result.Cache[*gtsmodel.Mention] + // Media provides access to the gtsmodel Media database cache. + Media() *result.Cache[*gtsmodel.MediaAttachment] + // Notification provides access to the gtsmodel Notification database cache. Notification() *result.Cache[*gtsmodel.Notification] @@ -81,6 +84,7 @@ type gtsCaches struct { domainBlock *domain.BlockCache emoji *result.Cache[*gtsmodel.Emoji] emojiCategory *result.Cache[*gtsmodel.EmojiCategory] + media *result.Cache[*gtsmodel.MediaAttachment] mention *result.Cache[*gtsmodel.Mention] notification *result.Cache[*gtsmodel.Notification] report *result.Cache[*gtsmodel.Report] @@ -95,6 +99,7 @@ func (c *gtsCaches) Init() { c.initDomainBlock() c.initEmoji() c.initEmojiCategory() + c.initMedia() c.initMention() c.initNotification() c.initReport() @@ -119,6 +124,9 @@ func (c *gtsCaches) Start() { tryUntil("starting gtsmodel.EmojiCategory cache", 5, func() bool { return c.emojiCategory.Start(config.GetCacheGTSEmojiCategorySweepFreq()) }) + tryUntil("starting gtsmodel.MediaAttachment cache", 5, func() bool { + return c.media.Start(config.GetCacheGTSMediaSweepFreq()) + }) tryUntil("starting gtsmodel.Mention cache", 5, func() bool { return c.mention.Start(config.GetCacheGTSMentionSweepFreq()) }) @@ -145,6 +153,7 @@ func (c *gtsCaches) Stop() { tryUntil("stopping gtsmodel.DomainBlock cache", 5, c.domainBlock.Stop) tryUntil("stopping gtsmodel.Emoji cache", 5, c.emoji.Stop) tryUntil("stopping gtsmodel.EmojiCategory cache", 5, c.emojiCategory.Stop) + tryUntil("stopping gtsmodel.MediaAttachment cache", 5, c.media.Stop) tryUntil("stopping gtsmodel.Mention cache", 5, c.mention.Stop) tryUntil("stopping gtsmodel.Notification cache", 5, c.notification.Stop) tryUntil("stopping gtsmodel.Report cache", 5, c.report.Stop) @@ -173,6 +182,10 @@ func (c *gtsCaches) EmojiCategory() *result.Cache[*gtsmodel.EmojiCategory] { return c.emojiCategory } +func (c *gtsCaches) Media() *result.Cache[*gtsmodel.MediaAttachment] { + return c.media +} + func (c *gtsCaches) Mention() *result.Cache[*gtsmodel.Mention] { return c.mention } @@ -258,6 +271,17 @@ func (c *gtsCaches) initEmojiCategory() { c.emojiCategory.SetTTL(config.GetCacheGTSEmojiCategoryTTL(), true) } +func (c *gtsCaches) initMedia() { + c.media = result.New([]result.Lookup{ + {Name: "ID"}, + }, func(m1 *gtsmodel.MediaAttachment) *gtsmodel.MediaAttachment { + m2 := new(gtsmodel.MediaAttachment) + *m2 = *m1 + return m2 + }, config.GetCacheGTSMediaMaxSize()) + c.media.SetTTL(config.GetCacheGTSMediaTTL(), true) +} + func (c *gtsCaches) initMention() { c.mention = result.New([]result.Lookup{ {Name: "ID"}, |