Skip to content

Commit fe2843e

Browse files
authored
Merge pull request #50 from initia-labs/chore/update-cache-unit
change cache unit to MiB
2 parents b3594fe + c066a05 commit fe2843e

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
3636

3737
## [Unreleased]
3838

39+
* (cache) Change cache-capacity unit to MiB
40+
3941
## [v0.1.5](https://github.com/initia-labs/kvindexer/releases/tag/v0.1.5) - 2024-07-16
4042

4143
### KVIndexer breaking

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (c IndexerConfig) IsEnabled() bool {
5959
func DefaultConfig() IndexerConfig {
6060
return IndexerConfig{
6161
Enable: true,
62-
CacheCapacity: 500 * 1024 * 1024, // 500MiB
62+
CacheCapacity: 500, // 500 MiB
6363
BackendConfig: store.DefaultConfig(),
6464
}
6565
}

config/types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ const DefaultConfigTemplate = `
2020
# Enable defines whether the indexer is enabled.
2121
enable = {{ .IndexerConfig.Enable }}
2222
23-
# CacheCapacity defines the size of the cache. (unit: bytes)
23+
# CacheCapacity defines the size of the cache. (unit: MiB)
2424
cache-capacity = {{ .IndexerConfig.CacheCapacity }}
2525
2626
# Backend defines the type of the backend store and its options.
2727
# It should have a key-value pair named 'type', and the value should exist in store supported by cosmos-db.
28+
# Recommend to use default value unless you know about backend db storage.
2829
# supported type: "goleveldb" only in current
2930
[indexer.backend]
3031
{{ range $key, $value := .IndexerConfig.BackendConfig.AllSettings }}{{ printf "%s = \"%v\"\n" $key $value }}{{end}}

x/kvindexer/keeper/keeper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (k *Keeper) Seal() error {
9999

100100
k.schema = &schema
101101

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

105105
return nil

0 commit comments

Comments
 (0)