This commit is contained in:
Neil Alexander 2022-06-17 10:15:49 +01:00
parent bf18f7d5ad
commit 7e9109510d
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
4 changed files with 23 additions and 9 deletions

View file

@ -41,6 +41,14 @@ global:
max_idle_conns: 5
conn_max_lifetime: -1
# Configuration for in-process caches, to help speed up processing transactions
# and reducing load on the database.
cache:
# The estimated maximum size for the global cache in bytes. Note that this is
# not a hard limit, nor is it a memory limit for the entire process. A cache that
# is too small may end up yielding little benefit.
max_bytes_est: 1073741824
# The server name to delegate server-server communications to, with optional port
# e.g. localhost:443
well_known_server_name: ""

View file

@ -31,6 +31,14 @@ global:
# considered valid by other homeservers.
key_validity_period: 168h0m0s
# Configuration for in-process caches, to help speed up processing transactions
# and reducing load on the database.
cache:
# The estimated maximum size for the global cache in bytes. Note that this is
# not a hard limit, nor is it a memory limit for the entire process. A cache that
# is too small may end up yielding little benefit.
max_bytes_est: 1073741824
# The server name to delegate server-server communications to, with optional port
# e.g. localhost:443
well_known_server_name: ""

View file

@ -161,7 +161,7 @@ func NewBaseDendrite(cfg *config.Dendrite, componentName string, options ...Base
}
}
cache, err := caching.NewRistrettoCache(cfg.Global.Caches.EstMaxSize, enableMetrics)
cache, err := caching.NewRistrettoCache(cfg.Global.Cache.EstMaxSize, enableMetrics)
if err != nil {
logrus.WithError(err).Warnf("Failed to create cache")
}

View file

@ -75,7 +75,7 @@ type Global struct {
ReportStats ReportStats `yaml:"report_stats"`
// Configuration for the caches.
Caches Caches `yaml:"caches"`
Cache Cache `yaml:"cache"`
}
func (c *Global) Defaults(generate bool) {
@ -93,7 +93,7 @@ func (c *Global) Defaults(generate bool) {
c.Sentry.Defaults()
c.ServerNotices.Defaults(generate)
c.ReportStats.Defaults()
c.Caches.Defaults(generate)
c.Cache.Defaults(generate)
}
func (c *Global) Verify(configErrs *ConfigErrors, isMonolith bool) {
@ -106,7 +106,7 @@ func (c *Global) Verify(configErrs *ConfigErrors, isMonolith bool) {
c.DNSCache.Verify(configErrs, isMonolith)
c.ServerNotices.Verify(configErrs, isMonolith)
c.ReportStats.Verify(configErrs, isMonolith)
c.Caches.Verify(configErrs, isMonolith)
c.Cache.Verify(configErrs, isMonolith)
}
type OldVerifyKeys struct {
@ -173,17 +173,15 @@ func (c *ServerNotices) Defaults(generate bool) {
func (c *ServerNotices) Verify(errors *ConfigErrors, isMonolith bool) {}
type Caches struct {
Enabled bool `yaml:"enabled"`
type Cache struct {
EstMaxSize int64 `yaml:"max_bytes_est"`
}
func (c *Caches) Defaults(generate bool) {
c.Enabled = true
func (c *Cache) Defaults(generate bool) {
c.EstMaxSize = 1024 * 1024 * 1024 // 1GB
}
func (c *Caches) Verify(errors *ConfigErrors, isMonolith bool) {
func (c *Cache) Verify(errors *ConfigErrors, isMonolith bool) {
checkPositive(errors, "max_bytes_est", int64(c.EstMaxSize))
}