From a47219b98246a5105f920863656f230f078281ab Mon Sep 17 00:00:00 2001 From: Vritra4 Date: Wed, 17 Jul 2024 20:19:27 +0900 Subject: [PATCH 1/3] change cache unit to MiB --- config/config.go | 2 +- config/types.go | 1 + x/kvindexer/keeper/keeper.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index 76d0a58..15c468f 100644 --- a/config/config.go +++ b/config/config.go @@ -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(), } } diff --git a/config/types.go b/config/types.go index dc43bfe..b2e47e3 100644 --- a/config/types.go +++ b/config/types.go @@ -25,6 +25,7 @@ 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}} diff --git a/x/kvindexer/keeper/keeper.go b/x/kvindexer/keeper/keeper.go index b9dd734..b86850a 100644 --- a/x/kvindexer/keeper/keeper.go +++ b/x/kvindexer/keeper/keeper.go @@ -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 From ca2c2def937fbf0aaf8888c69a164cfb4eca662c Mon Sep 17 00:00:00 2001 From: Vritra4 Date: Wed, 17 Jul 2024 20:25:19 +0900 Subject: [PATCH 2/3] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 826aeeb..16fb823 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From c066a0559abe7a1dffca622943db20ee0e80e706 Mon Sep 17 00:00:00 2001 From: Vritra4 Date: Wed, 17 Jul 2024 20:38:28 +0900 Subject: [PATCH 3/3] fix comments in config template --- config/types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/types.go b/config/types.go index b2e47e3..70f56ab 100644 --- a/config/types.go +++ b/config/types.go @@ -20,7 +20,7 @@ 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.