diff options
Diffstat (limited to 'internal/cache')
| -rw-r--r-- | internal/cache/cache.go | 7 | ||||
| -rw-r--r-- | internal/cache/util.go | 6 | 
2 files changed, 13 insertions, 0 deletions
| diff --git a/internal/cache/cache.go b/internal/cache/cache.go index e981d79b1..510b6eb53 100644 --- a/internal/cache/cache.go +++ b/internal/cache/cache.go @@ -19,6 +19,7 @@ package cache  import (  	"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" +	"github.com/superseriousbusiness/gotosocial/internal/log"  )  type Caches struct { @@ -41,6 +42,8 @@ type Caches struct {  // Init will (re)initialize both the GTS and AP cache collections.  // NOTE: the cache MUST NOT be in use anywhere, this is not thread-safe.  func (c *Caches) Init() { +	log.Infof(nil, "init: %p", c) +  	c.GTS.Init()  	c.AP.Init()  	c.Visibility.Init() @@ -52,6 +55,8 @@ func (c *Caches) Init() {  // Start will start both the GTS and AP cache collections.  func (c *Caches) Start() { +	log.Infof(nil, "start: %p", c) +  	c.GTS.Start()  	c.AP.Start()  	c.Visibility.Start() @@ -59,6 +64,8 @@ func (c *Caches) Start() {  // Stop will stop both the GTS and AP cache collections.  func (c *Caches) Stop() { +	log.Infof(nil, "stop: %p", c) +  	c.GTS.Stop()  	c.AP.Stop()  	c.Visibility.Stop() diff --git a/internal/cache/util.go b/internal/cache/util.go index ba4a43fdd..2d7badf68 100644 --- a/internal/cache/util.go +++ b/internal/cache/util.go @@ -74,8 +74,14 @@ func tryStop[ValueType any](cache *result.Cache[ValueType], sweep time.Duration)  func tryUntil(msg string, count int, do func() bool) {  	for i := 0; i < count; i++ {  		if do() { +			// success.  			return  		} + +		// Sleep for a little before retry (a bcakoff). +		time.Sleep(time.Millisecond * 1 << (i + 1))  	} + +	// panic on total failure as this shouldn't happen.  	log.Panicf(nil, "failed %s after %d tries", msg, count)  } | 
