Skip to content

Commit

Permalink
idcache configuration
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj committed May 19, 2023
1 parent 429389a commit f81fbbc
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/id-cache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Configurable ID Cache

Makes the integrated idcache (used to reduce reads from disc) configurable with the general cache envvars

https://github.com/owncloud/ocis/pull/6353
10 changes: 10 additions & 0 deletions services/storage-users/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Config struct {
Events Events `yaml:"events"`
StatCache StatCache `yaml:"stat_cache"`
FilemetadataCache FilemetadataCache `yaml:"filemetadata_cache"`
IDCache IDCache `yaml:"id_cache"`
MountID string `yaml:"mount_id" env:"STORAGE_USERS_MOUNT_ID" desc:"Mount ID of this storage."`
ExposeDataServer bool `yaml:"expose_data_server" env:"STORAGE_USERS_EXPOSE_DATA_SERVER" desc:"Exposes the data server directly to users and bypasses the data gateway. Ensure that the data server address is reachable by users."`
ReadOnly bool `yaml:"readonly" env:"STORAGE_USERS_READ_ONLY" desc:"Set this storage to be read-only."`
Expand Down Expand Up @@ -188,6 +189,15 @@ type FilemetadataCache struct {
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."`
}

// IDCache holds cache config
type IDCache struct {
Store string `yaml:"store" env:"OCIS_CACHE_STORE;STORAGE_USERS_ID_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_ID_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_ID_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_ID_CACHE_SIZE" desc:"The maximum quantity of items in the user info cache. Only applies when store type 'ocmem' is configured. Defaults to 512."`
}

// S3Driver is the storage driver configuration when using 's3' storage driver
type S3Driver struct {
// Root is the absolute path to the location of the data
Expand Down
28 changes: 28 additions & 0 deletions services/storage-users/pkg/revaconfig/drivers.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ func Ocis(cfg *config.Config) map[string]interface{} {
"cache_ttl": cfg.FilemetadataCache.TTL / time.Second,
"cache_size": cfg.FilemetadataCache.Size,
},
"idcache": map[string]interface{}{
"cache_store": cfg.IDCache.Store,
"cache_nodes": cfg.IDCache.Nodes,
"cache_database": cfg.IDCache.Database,
"cache_ttl": cfg.IDCache.TTL / time.Second,
"cache_size": cfg.IDCache.Size,
},
"events": map[string]interface{}{
"natsaddress": cfg.Events.Addr,
"natsclusterid": cfg.Events.ClusterID,
Expand Down Expand Up @@ -191,6 +198,13 @@ func OcisNoEvents(cfg *config.Config) map[string]interface{} {
"cache_ttl": cfg.FilemetadataCache.TTL / time.Second,
"cache_size": cfg.FilemetadataCache.Size,
},
"idcache": map[string]interface{}{
"cache_store": cfg.IDCache.Store,
"cache_nodes": cfg.IDCache.Nodes,
"cache_database": cfg.IDCache.Database,
"cache_ttl": cfg.IDCache.TTL / time.Second,
"cache_size": cfg.IDCache.Size,
},
}
}

Expand Down Expand Up @@ -243,6 +257,13 @@ func S3NG(cfg *config.Config) map[string]interface{} {
"cache_ttl": cfg.FilemetadataCache.TTL / time.Second,
"cache_size": cfg.FilemetadataCache.Size,
},
"idcache": map[string]interface{}{
"cache_store": cfg.IDCache.Store,
"cache_nodes": cfg.IDCache.Nodes,
"cache_database": cfg.IDCache.Database,
"cache_ttl": cfg.IDCache.TTL / time.Second,
"cache_size": cfg.IDCache.Size,
},
"events": map[string]interface{}{
"natsaddress": cfg.Events.Addr,
"natsclusterid": cfg.Events.ClusterID,
Expand Down Expand Up @@ -294,5 +315,12 @@ func S3NGNoEvents(cfg *config.Config) map[string]interface{} {
"cache_ttl": cfg.FilemetadataCache.TTL / time.Second,
"cache_size": cfg.FilemetadataCache.Size,
},
"idcache": map[string]interface{}{
"cache_store": cfg.IDCache.Store,
"cache_nodes": cfg.IDCache.Nodes,
"cache_database": cfg.IDCache.Database,
"cache_ttl": cfg.IDCache.TTL / time.Second,
"cache_size": cfg.IDCache.Size,
},
}
}

0 comments on commit f81fbbc

Please sign in to comment.