Cleanup and improve the caching config (#6148)

* Cleanup and improve the caching config

* bump reva

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* disable stat cache

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* Bump reva

* Linter fixes

---------

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
Co-authored-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Andre Duffeck
2023-04-27 12:35:30 +02:00
committed by GitHub
co-authored by Jörn Friedrich Dreyer
parent d563b63d8f
commit 129489203b
29 changed files with 277 additions and 253 deletions
+2 -2
View File
@@ -175,7 +175,7 @@ type StatCache struct {
Store string `yaml:"store" env:"OCIS_CACHE_STORE;STORAGE_USERS_STAT_CACHE_STORE" desc:"The type of the cache store. Supported values are: 'memory', 'ocmem', 'etcd', 'redis', 'redis-sentinel', 'nats-js', 'noop'. See the text description for details."`
Nodes []string `yaml:"nodes" env:"OCIS_CACHE_STORE_NODES;STORAGE_USERS_STAT_CACHE_STORE_NODES" desc:"A comma separated list of nodes to access the configured store. This has no effect when 'memory' or 'ocmem' stores are configured. Note that the behaviour how nodes are used is dependent on the library of the configured store."`
Database string `yaml:"database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use."`
TTL time.Duration `yaml:"ttl" env:"OCIS_CACHE_TTL;STORAGE_USERS_STAT_CACHE_TTL" desc:"Default time to live for user info in the user info cache. Only applied when access tokens has no expiration. The duration can be set as number followed by a unit identifier like s, m or h. Defaults to '10s' (10 seconds)."`
TTL time.Duration `yaml:"ttl" env:"OCIS_CACHE_TTL;STORAGE_USERS_STAT_CACHE_TTL" desc:"Default time to live for user info in the user info cache. Only applied when access tokens has no expiration. The duration can be set as number followed by a unit identifier like s, m or h. Defaults to '300s' (300 seconds)."`
Size int `yaml:"size" env:"OCIS_CACHE_SIZE;STORAGE_USERS_STAT_CACHE_SIZE" desc:"The maximum quantity of items in the user info cache. Only applies when store type 'ocmem' is configured. Defaults to 512."`
}
@@ -184,7 +184,7 @@ type FilemetadataCache struct {
Store string `yaml:"store" env:"OCIS_CACHE_STORE;STORAGE_USERS_FILEMETADATA_CACHE_STORE" desc:"The type of the cache store. Supported values are: 'memory', 'ocmem', 'etcd', 'redis', 'redis-sentinel', 'nats-js', 'noop'. See the text description for details."`
Nodes []string `yaml:"nodes" env:"OCIS_CACHE_STORE_NODES;STORAGE_USERS_FILEMETADATA_CACHE_STORE_NODES" desc:"A comma separated list of nodes to access the configured store. This has no effect when 'memory' or 'ocmem' stores are configured. Note that the behaviour how nodes are used is dependent on the library of the configured store."`
Database string `yaml:"database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use."`
TTL time.Duration `yaml:"ttl" env:"OCIS_CACHE_TTL;STORAGE_USERS_FILEMETADATA_CACHE_TTL" desc:"Default time to live for user info in the user info cache. Only applied when access tokens has no expiration. The duration can be set as number followed by a unit identifier like s, m or h. Defaults to '10s' (10 seconds)."`
TTL time.Duration `yaml:"ttl" env:"OCIS_CACHE_TTL;STORAGE_USERS_FILEMETADATA_CACHE_TTL" desc:"Default time to live for user info in the user info cache. Only applied when access tokens has no expiration. The duration can be set as number followed by a unit identifier like s, m or h. Defaults to '24h' (24 hours)."`
Size int `yaml:"size" env:"OCIS_CACHE_SIZE;STORAGE_USERS_FILEMETADATA_CACHE_SIZE" desc:"The maximum quantity of items in the user info cache. Only applies when store type 'ocmem' is configured. Defaults to 512."`
}
@@ -90,12 +90,14 @@ func DefaultConfig() *config.Config {
EnableTLS: false,
},
StatCache: config.StatCache{
Store: "memory",
Store: "noop",
Database: "ocis",
TTL: 300 * time.Second,
},
FilemetadataCache: config.FilemetadataCache{
Store: "memory",
Database: "ocis",
TTL: 24 * 60 * time.Second,
},
Tasks: config.Tasks{
PurgeTrashBin: config.PurgeTrashBin{
@@ -1,6 +1,8 @@
package revaconfig
import (
"time"
"github.com/owncloud/ocis/v2/services/storage-users/pkg/config"
)
@@ -76,7 +78,7 @@ func StorageUsersConfigFromStruct(cfg *config.Config) map[string]interface{} {
"cache_store": cfg.StatCache.Store,
"cache_nodes": cfg.StatCache.Nodes,
"cache_database": cfg.StatCache.Database,
"cache_ttl": cfg.StatCache.TTL,
"cache_ttl": cfg.StatCache.TTL / time.Second,
"cache_size": cfg.StatCache.Size,
"cache_table": "stat",
},
@@ -84,7 +86,7 @@ func StorageUsersConfigFromStruct(cfg *config.Config) map[string]interface{} {
"cache_store": cfg.StatCache.Store,
"cache_nodes": cfg.StatCache.Nodes,
"cache_database": cfg.StatCache.Database,
"cache_ttl": cfg.StatCache.TTL,
"cache_ttl": cfg.StatCache.TTL / time.Second,
"cache_size": cfg.StatCache.Size,
"cache_table": "stat",
},
@@ -92,7 +94,7 @@ func StorageUsersConfigFromStruct(cfg *config.Config) map[string]interface{} {
"cache_store": cfg.StatCache.Store,
"cache_nodes": cfg.StatCache.Nodes,
"cache_database": cfg.StatCache.Database,
"cache_ttl": cfg.StatCache.TTL,
"cache_ttl": cfg.StatCache.TTL / time.Second,
"cache_size": cfg.StatCache.Size,
"cache_table": "stat",
},
@@ -1,6 +1,10 @@
package revaconfig
import "github.com/owncloud/ocis/v2/services/storage-users/pkg/config"
import (
"time"
"github.com/owncloud/ocis/v2/services/storage-users/pkg/config"
)
// EOS is the config mapping for the EOS storage driver
func EOS(cfg *config.Config) map[string]interface{} {
@@ -130,14 +134,14 @@ func Ocis(cfg *config.Config) map[string]interface{} {
"cache_store": cfg.StatCache.Store,
"cache_nodes": cfg.StatCache.Nodes,
"cache_database": cfg.StatCache.Database,
"cache_ttl": cfg.StatCache.TTL,
"cache_ttl": cfg.StatCache.TTL / time.Second,
"cache_size": cfg.StatCache.Size,
},
"filemetadatacache": map[string]interface{}{
"cache_store": cfg.FilemetadataCache.Store,
"cache_nodes": cfg.FilemetadataCache.Nodes,
"cache_database": cfg.FilemetadataCache.Database,
"cache_ttl": cfg.FilemetadataCache.TTL,
"cache_ttl": cfg.FilemetadataCache.TTL / time.Second,
"cache_size": cfg.FilemetadataCache.Size,
},
"events": map[string]interface{}{
@@ -177,14 +181,14 @@ func OcisNoEvents(cfg *config.Config) map[string]interface{} {
"cache_store": cfg.StatCache.Store,
"cache_nodes": cfg.StatCache.Nodes,
"cache_database": cfg.StatCache.Database,
"cache_ttl": cfg.StatCache.TTL,
"cache_ttl": cfg.StatCache.TTL / time.Second,
"cache_size": cfg.StatCache.Size,
},
"filemetadatacache": map[string]interface{}{
"cache_store": cfg.FilemetadataCache.Store,
"cache_nodes": cfg.FilemetadataCache.Nodes,
"cache_database": cfg.FilemetadataCache.Database,
"cache_ttl": cfg.FilemetadataCache.TTL,
"cache_ttl": cfg.FilemetadataCache.TTL / time.Second,
"cache_size": cfg.FilemetadataCache.Size,
},
}
@@ -229,14 +233,14 @@ func S3NG(cfg *config.Config) map[string]interface{} {
"cache_store": cfg.StatCache.Store,
"cache_nodes": cfg.StatCache.Nodes,
"cache_database": cfg.StatCache.Database,
"cache_ttl": cfg.StatCache.TTL,
"cache_ttl": cfg.StatCache.TTL / time.Second,
"cache_size": cfg.StatCache.Size,
},
"filemetadatacache": map[string]interface{}{
"cache_store": cfg.FilemetadataCache.Store,
"cache_nodes": cfg.FilemetadataCache.Nodes,
"cache_database": cfg.FilemetadataCache.Database,
"cache_ttl": cfg.FilemetadataCache.TTL,
"cache_ttl": cfg.FilemetadataCache.TTL / time.Second,
"cache_size": cfg.FilemetadataCache.Size,
},
"events": map[string]interface{}{
@@ -280,14 +284,14 @@ func S3NGNoEvents(cfg *config.Config) map[string]interface{} {
"cache_store": cfg.StatCache.Store,
"cache_nodes": cfg.StatCache.Nodes,
"cache_database": cfg.StatCache.Database,
"cache_ttl": cfg.StatCache.TTL,
"cache_ttl": cfg.StatCache.TTL / time.Second,
"cache_size": cfg.StatCache.Size,
},
"filemetadatacache": map[string]interface{}{
"cache_store": cfg.FilemetadataCache.Store,
"cache_nodes": cfg.FilemetadataCache.Nodes,
"cache_database": cfg.FilemetadataCache.Database,
"cache_ttl": cfg.FilemetadataCache.TTL,
"cache_ttl": cfg.FilemetadataCache.TTL / time.Second,
"cache_size": cfg.FilemetadataCache.Size,
},
}