From 23a26f2ea610146db2e62741789d9a56ae5a4aae Mon Sep 17 00:00:00 2001 From: Alexander Cristurean Date: Fri, 13 Sep 2024 16:03:26 +0300 Subject: [PATCH] replaced timer behaviour with ticker. --- timecache/timeCacher.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/timecache/timeCacher.go b/timecache/timeCacher.go index 21441afa..ea4091c8 100644 --- a/timecache/timeCacher.go +++ b/timecache/timeCacher.go @@ -7,6 +7,7 @@ import ( "time" logger "github.com/multiversx/mx-chain-logger-go" + "github.com/multiversx/mx-chain-storage-go/common" ) @@ -63,14 +64,12 @@ func checkArg(arg ArgTimeCacher) error { // startSweeping handles sweeping the time cache func (tc *timeCacher) startSweeping(ctx context.Context) { - timer := time.NewTimer(tc.cacheExpiry) - defer timer.Stop() + ticker := time.NewTicker(tc.cacheExpiry) + defer ticker.Stop() for { - timer.Reset(tc.cacheExpiry) - select { - case <-timer.C: + case <-ticker.C: tc.timeCache.sweep() case <-ctx.Done(): log.Info("closing mapTimeCacher's sweep go routine...")