diff options
Diffstat (limited to 'internal/cache/db.go')
-rw-r--r-- | internal/cache/db.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/internal/cache/db.go b/internal/cache/db.go index 00dfe204a..ff38c1d93 100644 --- a/internal/cache/db.go +++ b/internal/cache/db.go @@ -43,6 +43,9 @@ type GTSCaches struct { Pinned int }] + // AccountSettings provides access to the gtsmodel AccountSettings database cache. + AccountSettings structr.Cache[*gtsmodel.AccountSettings] + // Application provides access to the gtsmodel Application database cache. Application structr.Cache[*gtsmodel.Application] @@ -190,6 +193,7 @@ func (c *Caches) initAccount() { a2.Emojis = nil a2.AlsoKnownAs = nil a2.Move = nil + a2.Settings = nil return a2 } @@ -262,6 +266,29 @@ func (c *Caches) initAccountNote() { }) } +func (c *Caches) initAccountSettings() { + // Calculate maximum cache size. + cap := calculateResultCacheMax( + sizeofAccountSettings(), // model in-mem size. + config.GetCacheAccountSettingsMemRatio(), + ) + + log.Infof(nil, "cache size = %d", cap) + + c.GTS.AccountSettings.Init(structr.Config[*gtsmodel.AccountSettings]{ + Indices: []structr.IndexConfig{ + {Fields: "AccountID"}, + }, + MaxSize: cap, + IgnoreErr: ignoreErrors, + CopyValue: func(s1 *gtsmodel.AccountSettings) *gtsmodel.AccountSettings { + s2 := new(gtsmodel.AccountSettings) + *s2 = *s1 + return s2 + }, + }) +} + func (c *Caches) initApplication() { // Calculate maximum cache size. cap := calculateResultCacheMax( |