[chore] Move local account settings to separate db table (#2770)

* [chore] Move local account settings to separate database model

* don't use separate settings_id
This commit is contained in:
tobi
2024-03-22 14:03:46 +01:00
committed by GitHub
parent 0767647056
commit 7f4a0a1aeb
36 changed files with 525 additions and 191 deletions

27
internal/cache/db.go vendored
View File

@@ -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(