diff options
author | 2023-07-29 03:49:14 -0700 | |
---|---|---|
committer | 2023-07-29 12:49:14 +0200 | |
commit | b874e9251e00961f295e4c409e1b34da89fab4ed (patch) | |
tree | cb528816250f322707a90c0954c963886ea96c19 /internal/cache/gts.go | |
parent | [chore] Update activity dependency (#2031) (diff) | |
download | gotosocial-b874e9251e00961f295e4c409e1b34da89fab4ed.tar.xz |
[feature] Implement markers API (#1989)
* Implement markers API
Fixes #1856
* Correct import grouping in markers files
* Regenerate Swagger for markers API
* Shorten names for readability
* Cache markers for 6 hours
* Update DB ref
* Update envparsing.sh
Diffstat (limited to 'internal/cache/gts.go')
-rw-r--r-- | internal/cache/gts.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/cache/gts.go b/internal/cache/gts.go index 81c6e9f9e..dd43154ef 100644 --- a/internal/cache/gts.go +++ b/internal/cache/gts.go @@ -39,6 +39,7 @@ type GTSCaches struct { instance *result.Cache[*gtsmodel.Instance] list *result.Cache[*gtsmodel.List] listEntry *result.Cache[*gtsmodel.ListEntry] + marker *result.Cache[*gtsmodel.Marker] media *result.Cache[*gtsmodel.MediaAttachment] mention *result.Cache[*gtsmodel.Mention] notification *result.Cache[*gtsmodel.Notification] @@ -65,6 +66,7 @@ func (c *GTSCaches) Init() { c.initInstance() c.initList() c.initListEntry() + c.initMarker() c.initMedia() c.initMention() c.initNotification() @@ -88,6 +90,7 @@ func (c *GTSCaches) Start() { tryStart(c.instance, config.GetCacheGTSInstanceSweepFreq()) tryStart(c.list, config.GetCacheGTSListSweepFreq()) tryStart(c.listEntry, config.GetCacheGTSListEntrySweepFreq()) + tryStart(c.marker, config.GetCacheGTSMarkerSweepFreq()) tryStart(c.media, config.GetCacheGTSMediaSweepFreq()) tryStart(c.mention, config.GetCacheGTSMentionSweepFreq()) tryStart(c.notification, config.GetCacheGTSNotificationSweepFreq()) @@ -116,6 +119,7 @@ func (c *GTSCaches) Stop() { tryStop(c.instance, config.GetCacheGTSInstanceSweepFreq()) tryStop(c.list, config.GetCacheGTSListSweepFreq()) tryStop(c.listEntry, config.GetCacheGTSListEntrySweepFreq()) + tryStop(c.marker, config.GetCacheGTSMarkerSweepFreq()) tryStop(c.media, config.GetCacheGTSMediaSweepFreq()) tryStop(c.mention, config.GetCacheGTSNotificationSweepFreq()) tryStop(c.notification, config.GetCacheGTSNotificationSweepFreq()) @@ -182,6 +186,11 @@ func (c *GTSCaches) ListEntry() *result.Cache[*gtsmodel.ListEntry] { return c.listEntry } +// Marker provides access to the gtsmodel Marker database cache. +func (c *GTSCaches) Marker() *result.Cache[*gtsmodel.Marker] { + return c.marker +} + // Media provides access to the gtsmodel Media database cache. func (c *GTSCaches) Media() *result.Cache[*gtsmodel.MediaAttachment] { return c.media @@ -372,6 +381,18 @@ func (c *GTSCaches) initListEntry() { c.list.IgnoreErrors(ignoreErrors) } +func (c *GTSCaches) initMarker() { + c.marker = result.New([]result.Lookup{ + {Name: "AccountID.Name"}, + }, func(m1 *gtsmodel.Marker) *gtsmodel.Marker { + m2 := new(gtsmodel.Marker) + *m2 = *m1 + return m2 + }, config.GetCacheGTSMarkerMaxSize()) + c.marker.SetTTL(config.GetCacheGTSMarkerTTL(), true) + c.marker.IgnoreErrors(ignoreErrors) +} + func (c *GTSCaches) initMedia() { c.media = result.New([]result.Lookup{ {Name: "ID"}, |