diff options
author | 2025-01-22 12:42:12 +0000 | |
---|---|---|
committer | 2025-01-22 13:42:12 +0100 | |
commit | 0a99901c657909a605a7f1c6a4ede282ba01ce43 (patch) | |
tree | a8b3f1bba879b051db41b18e1707d0c90e315a20 /internal/cache | |
parent | [chore]: Bump github.com/coreos/go-oidc/v3 from 3.11.0 to 3.12.0 (#3662) (diff) | |
download | gotosocial-0a99901c657909a605a7f1c6a4ede282ba01ce43.tar.xz |
[performance] reduce InboxForward->Create calls by partially implementing Exists() (#3647)
* alphabetical reordering
* keep a cache of activity IDs we have handled creates for
* reduce number of inbox forwarding create calls by partially implementing Exists()
* increase cache size, since all we're storing is string keys
Diffstat (limited to 'internal/cache')
-rw-r--r-- | internal/cache/cache.go | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/internal/cache/cache.go b/internal/cache/cache.go index 560fbc9f6..6f925e24f 100644 --- a/internal/cache/cache.go +++ b/internal/cache/cache.go @@ -40,6 +40,11 @@ type Caches struct { // the block []headerfilter.Filter cache. BlockHeaderFilters headerfilter.Cache + // TTL cache of statuses -> filterable text fields. + // To ensure up-to-date fields, cache is keyed as: + // `[status.ID][status.UpdatedAt.Unix()]` + StatusesFilterableFields *ttl.Cache[string, []string] + // Visibility provides access to the item visibility // cache. (used by the visibility filter). Visibility VisibilityCache @@ -47,11 +52,6 @@ type Caches struct { // Webfinger provides access to the webfinger URL cache. Webfinger *ttl.Cache[string, string] // TTL=24hr, sweep=5min - // TTL cache of statuses -> filterable text fields. - // To ensure up-to-date fields, cache is keyed as: - // `[status.ID][status.UpdatedAt.Unix()]` - StatusesFilterableFields *ttl.Cache[string, []string] - // prevent pass-by-value. _ nocopy } @@ -203,6 +203,15 @@ func (c *Caches) Sweep(threshold float64) { c.Visibility.Trim(threshold) } +func (c *Caches) initStatusesFilterableFields() { + c.StatusesFilterableFields = new(ttl.Cache[string, []string]) + c.StatusesFilterableFields.Init( + 0, + 512, + 1*time.Hour, + ) +} + func (c *Caches) initWebfinger() { // Calculate maximum cache size. cap := calculateCacheMax( @@ -219,12 +228,3 @@ func (c *Caches) initWebfinger() { 24*time.Hour, ) } - -func (c *Caches) initStatusesFilterableFields() { - c.StatusesFilterableFields = new(ttl.Cache[string, []string]) - c.StatusesFilterableFields.Init( - 0, - 512, - 1*time.Hour, - ) -} |