1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-07-04 12:03:41 +02:00

cmd/thalos/main.go: pass context to cache.

This commit is contained in:
Henrik Hautakoski 2023-12-17 17:58:42 +01:00
parent 1d5e28a38f
commit 41ab39d4a3

View file

@ -187,7 +187,9 @@ func stateLoader(chainInfo *eos.InfoResp, current_block_no_cache bool) app.State
var source string var source string
// Load state from cache. // Load state from cache.
err := cache.Get("state", &state) ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*500)
err := cache.Get(ctx, "state", &state)
cancel()
// on error (cache miss) or if current_block_no_cache is set. // on error (cache miss) or if current_block_no_cache is set.
// set current block from config/api // set current block from config/api
@ -218,7 +220,9 @@ func stateLoader(chainInfo *eos.InfoResp, current_block_no_cache bool) app.State
} }
func stateSaver(state app.State) error { func stateSaver(state app.State) error {
return cache.Set("state", state, 0) ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*500)
defer cancel()
return cache.Set(ctx, "state", state, 0)
} }
func main() { func main() {