Skip to content

Commit

Permalink
replaced timer behaviour with ticker.
Browse files Browse the repository at this point in the history
  • Loading branch information
cristure committed Sep 13, 2024
1 parent 8704d43 commit 23a26f2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions timecache/timeCacher.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

logger "github.com/multiversx/mx-chain-logger-go"

"github.com/multiversx/mx-chain-storage-go/common"
)

Expand Down Expand Up @@ -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...")
Expand Down

0 comments on commit 23a26f2

Please sign in to comment.