[feature] do not uncache status / emoji media if attached status is bookmarked (#2956)

* do not uncache status / emoji media if attached status is bookmarked

* add status bookmark and bookmark IDs caches

* update status bookmark tests

* move IsStatusBookmarkedBy() to StatusBookmark{} interface, rely on cache

* fix envparsing.sh test
This commit is contained in:
kim 2024-06-06 10:44:43 +00:00 committed by GitHub
commit 5dcc954072
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 501 additions and 215 deletions

View file

@ -85,6 +85,8 @@ func (c *Caches) Init() {
c.initPollVoteIDs()
c.initReport()
c.initStatus()
c.initStatusBookmark()
c.initStatusBookmarkIDs()
c.initStatusFave()
c.initStatusFaveIDs()
c.initTag()
@ -101,7 +103,7 @@ func (c *Caches) Init() {
func (c *Caches) Start() {
log.Infof(nil, "start: %p", c)
tryUntil("starting *gtsmodel.Webfinger cache", 5, func() bool {
tryUntil("starting webfinger cache", 5, func() bool {
return c.GTS.Webfinger.Start(5 * time.Minute)
})
}
@ -111,7 +113,7 @@ func (c *Caches) Start() {
func (c *Caches) Stop() {
log.Infof(nil, "stop: %p", c)
tryUntil("stopping *gtsmodel.Webfinger cache", 5, c.GTS.Webfinger.Stop)
tryUntil("stopping webfinger cache", 5, c.GTS.Webfinger.Stop)
}
// Sweep will sweep all the available caches to ensure none
@ -153,6 +155,8 @@ func (c *Caches) Sweep(threshold float64) {
c.GTS.PollVoteIDs.Trim(threshold)
c.GTS.Report.Trim(threshold)
c.GTS.Status.Trim(threshold)
c.GTS.StatusBookmark.Trim(threshold)
c.GTS.StatusBookmarkIDs.Trim(threshold)
c.GTS.StatusFave.Trim(threshold)
c.GTS.StatusFaveIDs.Trim(threshold)
c.GTS.Tag.Trim(threshold)