Skip to content

Commit

Permalink
Merge pull request #50 from initia-labs/chore/update-cache-unit
Browse files Browse the repository at this point in the history
change cache unit to MiB
  • Loading branch information
Vritra4 authored Jul 18, 2024
2 parents b3594fe + c066a05 commit fe2843e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

* (cache) Change cache-capacity unit to MiB

## [v0.1.5](https://github.com/initia-labs/kvindexer/releases/tag/v0.1.5) - 2024-07-16

### KVIndexer breaking
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (c IndexerConfig) IsEnabled() bool {
func DefaultConfig() IndexerConfig {
return IndexerConfig{
Enable: true,
CacheCapacity: 500 * 1024 * 1024, // 500MiB
CacheCapacity: 500, // 500 MiB
BackendConfig: store.DefaultConfig(),
}
}
3 changes: 2 additions & 1 deletion config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ const DefaultConfigTemplate = `
# Enable defines whether the indexer is enabled.
enable = {{ .IndexerConfig.Enable }}
# CacheCapacity defines the size of the cache. (unit: bytes)
# CacheCapacity defines the size of the cache. (unit: MiB)
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.
# Recommend to use default value unless you know about backend db storage.
# supported type: "goleveldb" only in current
[indexer.backend]
{{ range $key, $value := .IndexerConfig.BackendConfig.AllSettings }}{{ printf "%s = \"%v\"\n" $key $value }}{{end}}
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 @@ -99,7 +99,7 @@ func (k *Keeper) Seal() error {

k.schema = &schema

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

return nil
Expand Down

0 comments on commit fe2843e

Please sign in to comment.