Closed DoubleDi closed 10 months ago
@swithek @davseby Hi! Please check the latest version.
Please note, that the GetOrSet func has changed. The current version, when the loader is defined returns a loaded item from the loader, and only if the loaded item is nil will set the new value. The new version, when the loader is defined does not search the loader at all if the item is not present in the cache and directly sets the new value
I assume the new logic is better, because when you call GetOrSet you already have a preloaded value, that you pass and you do not want to preload it again internally in the cache
@davseby @swithek Please check when you have the time
@DoubleDi will do, later today/tomorrow.
@swithek when you have time please check
Thanks for your contribution @DoubleDi. Merging :)
as it is stated in #97 GetOrSet and GetAndDelete are not atomic.
This PR tries to resolve this problem
I am not sure about the reasons (maybe performance), that the lock was initially made in getWithOpts. Also a good followup question is - do we need the metricsMu at all if this PR will be merged?