[go-nuts] Re: sync.Map for caching

2017-08-31 Thread bep
Thanks, snmed, I was looking at LoadOrStore, but I was assuming that any func would be executed in any case. A more illustrative running sample of your first example: https://play.golang.org/p/vjlVu1GnUQ Thanks again! bep fredag 1. september 2017 08.24.10 UTC+2 skrev snmed følgende: > > Hi

[go-nuts] Re: sync.Map for caching

2017-08-31 Thread snmed
Hi Here are two examples how to achieve it: https://play.golang.org/p/wAtyGMSw6g or https://play.golang.org/p/EZWZUOpuwb First example: In best cases it executes the creator function once and returns always the stored item, in bad cases it executes the creator function multiple times but retu