cache2go icon indicating copy to clipboard operation
cache2go copied to clipboard

is item.RLock() among table.items‘s traversal in expirationCheck() necessary?

Open Deep-Coder-zhui opened this issue 5 years ago • 3 comments

because of the existing of table.Lock(),a table items‘s traversal is not concurrent, so I think item.RLock() may be not needed.

Deep-Coder-zhui avatar Oct 14 '19 03:10 Deep-Coder-zhui

I think you may be onto something indeed. It was there to protect the package's user from concurrently changing the CacheItem's properties. But since the only members we access are only mutable by the CacheTable itself, we could probably remove the lock.

muesli avatar Oct 14 '19 07:10 muesli

I get it, thanks @muesli

Deep-Coder-zhui avatar Oct 15 '19 03:10 Deep-Coder-zhui

HI @Deep-Coder-zhui / @muesli Removing the item lock causing the race condition(failure of go test --race). Can we close this issue without doing change.

vaibhavsanap avatar Dec 31 '20 05:12 vaibhavsanap