diff options
author | 2023-07-07 11:34:12 +0200 | |
---|---|---|
committer | 2023-07-07 11:34:12 +0200 | |
commit | e70bf8a6c82e3d5c943550b364fc6f8120f6f07e (patch) | |
tree | f408ccff2e6f2451bf95ee9a5d96e5b678d686d5 /internal/cache/gts.go | |
parent | [chore/performance] Remove remaining 'whereEmptyOrNull' funcs (#1946) (diff) | |
download | gotosocial-e70bf8a6c82e3d5c943550b364fc6f8120f6f07e.tar.xz |
[chore/bugfix] Domain block tidying up, Implement first pass of `207 Multi-Status` (#1886)
* [chore/refactor] update domain block processing
* expose domain block import errors a lil better
* move/remove unused query keys
Diffstat (limited to 'internal/cache/gts.go')
-rw-r--r-- | internal/cache/gts.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/cache/gts.go b/internal/cache/gts.go index 3a2d09736..4b2e65b9c 100644 --- a/internal/cache/gts.go +++ b/internal/cache/gts.go @@ -35,6 +35,7 @@ type GTSCaches struct { emojiCategory *result.Cache[*gtsmodel.EmojiCategory] follow *result.Cache[*gtsmodel.Follow] followRequest *result.Cache[*gtsmodel.FollowRequest] + instance *result.Cache[*gtsmodel.Instance] list *result.Cache[*gtsmodel.List] listEntry *result.Cache[*gtsmodel.ListEntry] media *result.Cache[*gtsmodel.MediaAttachment] @@ -59,6 +60,7 @@ func (c *GTSCaches) Init() { c.initEmojiCategory() c.initFollow() c.initFollowRequest() + c.initInstance() c.initList() c.initListEntry() c.initMedia() @@ -80,6 +82,7 @@ func (c *GTSCaches) Start() { tryStart(c.emojiCategory, config.GetCacheGTSEmojiCategorySweepFreq()) tryStart(c.follow, config.GetCacheGTSFollowSweepFreq()) tryStart(c.followRequest, config.GetCacheGTSFollowRequestSweepFreq()) + tryStart(c.instance, config.GetCacheGTSInstanceSweepFreq()) tryStart(c.list, config.GetCacheGTSListSweepFreq()) tryStart(c.listEntry, config.GetCacheGTSListEntrySweepFreq()) tryStart(c.media, config.GetCacheGTSMediaSweepFreq()) @@ -106,6 +109,7 @@ func (c *GTSCaches) Stop() { tryStop(c.emojiCategory, config.GetCacheGTSEmojiCategorySweepFreq()) tryStop(c.follow, config.GetCacheGTSFollowSweepFreq()) tryStop(c.followRequest, config.GetCacheGTSFollowRequestSweepFreq()) + tryStop(c.instance, config.GetCacheGTSInstanceSweepFreq()) tryStop(c.list, config.GetCacheGTSListSweepFreq()) tryStop(c.listEntry, config.GetCacheGTSListEntrySweepFreq()) tryStop(c.media, config.GetCacheGTSMediaSweepFreq()) @@ -154,6 +158,11 @@ func (c *GTSCaches) FollowRequest() *result.Cache[*gtsmodel.FollowRequest] { return c.followRequest } +// Instance provides access to the gtsmodel Instance database cache. +func (c *GTSCaches) Instance() *result.Cache[*gtsmodel.Instance] { + return c.instance +} + // List provides access to the gtsmodel List database cache. func (c *GTSCaches) List() *result.Cache[*gtsmodel.List] { return c.list @@ -301,6 +310,19 @@ func (c *GTSCaches) initFollowRequest() { c.followRequest.SetTTL(config.GetCacheGTSFollowRequestTTL(), true) } +func (c *GTSCaches) initInstance() { + c.instance = result.New([]result.Lookup{ + {Name: "ID"}, + {Name: "Domain"}, + }, func(i1 *gtsmodel.Instance) *gtsmodel.Instance { + i2 := new(gtsmodel.Instance) + *i2 = *i1 + return i1 + }, config.GetCacheGTSInstanceMaxSize()) + c.instance.SetTTL(config.GetCacheGTSInstanceTTL(), true) + c.emojiCategory.IgnoreErrors(ignoreErrors) +} + func (c *GTSCaches) initList() { c.list = result.New([]result.Lookup{ {Name: "ID"}, |