mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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:
27
internal/cache/db.go
vendored
27
internal/cache/db.go
vendored
@@ -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(
|
||||
|
Reference in New Issue
Block a user