Skip to content

Commit

Permalink
Rename cache size to cache capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
joon9823 committed Jul 9, 2024
1 parent 4cb4ff4 commit 05f6301
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ func NewConfig(appOpts servertypes.AppOptions) (*IndexerConfig, error) {
if !cfg.Enable {
return cfg, nil
}
cfg.CacheSize = cast.ToInt(appOpts.Get(flagIndexerCacheCapacity))
cfg.CacheCapacity = cast.ToInt(appOpts.Get(flagIndexerCacheCapacity))

cfg.BackendConfig = viper.New()
err := cfg.BackendConfig.MergeConfigMap(cast.ToStringMap(appOpts.Get(flagIndexerBackend)))
if err != nil {
return nil, fmt.Errorf("failed to merge backend config: %w", err)
}

cfg.CacheSize = cast.ToInt(appOpts.Get(flagIndexerCacheCapacity))
cfg.CacheCapacity = cast.ToInt(appOpts.Get(flagIndexerCacheCapacity))

return cfg, nil
}
Expand All @@ -41,7 +41,7 @@ func (c IndexerConfig) Validate() error {
return nil
}

if c.CacheSize == 0 {
if c.CacheCapacity == 0 {
return fmt.Errorf("cache capacity must be greater than 0")
}

Expand All @@ -59,7 +59,7 @@ func (c IndexerConfig) IsEnabled() bool {
func DefaultConfig() IndexerConfig {
return IndexerConfig{
Enable: true,
CacheSize: 500 * 1024 * 1024, // 500MiB
CacheCapacity: 500 * 1024 * 1024, // 500MiB
BackendConfig: store.DefaultConfig(),
}
}
6 changes: 3 additions & 3 deletions config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

type IndexerConfig struct {
Enable bool `mapstructure:"indexer.enable"`
CacheSize int `mapstructure:"indexer.cache-size"`
CacheCapacity int `mapstructure:"indexer.cache-capacity"`
BackendConfig *viper.Viper `mapstructure:"indexer.backend"`
}

Expand All @@ -20,8 +20,8 @@ const DefaultConfigTemplate = `
# Enable defines whether the indexer is enabled.
enable = {{ .IndexerConfig.Enable }}
# CacheSize defines the size of the cache. (unit: bytes)
cache-size = {{ .IndexerConfig.CacheSize }}
# CacheCapacity defines the size of the cache. (unit: bytes)
cache-capacity = {{ .IndexerConfig.CacheCapacity }}
# Backend defines the type of the backend store and its options.
# It should have a key-value pair named 'type', and the value should exist in store supported by cosmos-db.
Expand Down
2 changes: 1 addition & 1 deletion x/kvindexer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (k *Keeper) Seal() error {
k.db = db
k.schema = &schema

k.store = store.NewCacheStore(dbadapter.Store{DB: db}, k.config.CacheSize)
k.store = store.NewCacheStore(dbadapter.Store{DB: db}, k.config.CacheCapacity)
k.sealed = true

return nil
Expand Down

0 comments on commit 05f6301

Please sign in to comment.