This PR adds a GetOrSetFunc method to the cache. The main motivation for this was to avoid allocations when using the cache to store slices. GetOrSetFunc mirrors GetOrSet, however takes a valueFunc rather than a value. This function is only called if the key was not found in the cache, avoiding an unnecessary allocation and executing quicker.
I'm conscious I don't have a corresponding issue for this, so feel free to decline if this isn't something you think should be part of this library.
Hello,
This PR adds a
GetOrSetFunc
method to the cache. The main motivation for this was to avoid allocations when using the cache to storeslices
.GetOrSetFunc
mirrorsGetOrSet
, however takes avalueFunc
rather than avalue
. This function is only called if the key was not found in the cache, avoiding an unnecessary allocation and executing quicker.I'm conscious I don't have a corresponding issue for this, so feel free to decline if this isn't something you think should be part of this library.