golang / groupcache

groupcache is a caching and cache-filling library, intended as a replacement for memcached in many cases.
Apache License 2.0
12.94k stars 1.39k forks source link

singleflight: Add an example #73

Open kevinburke opened 8 years ago

kevinburke commented 8 years ago

I was curious about the best way to initialize a Group - it turns out you just do var g Group - but figured this package could use a package-level example demonstrating an example use case.

I've signed the CLA.

kevinburke commented 8 years ago

Here's how the example looks on godoc on my machine:

bradfitz commented 8 years ago

Check errors too.

kevinburke commented 8 years ago

Done. Thank you for the review! And sorry for being so slow.

$ git rev-parse HEAD && go test ./...
8340abafe7a8d6b5443f502e62eb1d8e16198d52
ok      github.com/golang/groupcache    0.691s
ok      github.com/golang/groupcache/consistenthash 0.011s
?       github.com/golang/groupcache/groupcachepb   [no test files]
ok      github.com/golang/groupcache/lru    0.012s
ok      github.com/golang/groupcache/singleflight   0.119s
?       github.com/golang/groupcache/testpb [no test files]
bradfitz commented 8 years ago

Copyright Google isn't right. You're not a Google employee I don't think?

I'd make it match the rest of Go and be copyright The Go Authors.

kevinburke commented 8 years ago

Ah, sorry, I copied it from another file in that repo. Should I update the other file headers or just this one?

On Saturday, October 29, 2016, Brad Fitzpatrick notifications@github.com wrote:

Copyright Google isn't right. You're not a Google employee I don't think?

I'd make it match the rest of Go and be copyright The Go Authors.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/golang/groupcache/pull/73#issuecomment-257103736, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOSI_80N7g_J8gylOG7N65zuy3FtDVoks5q439egaJpZM4KeD5v .

Kevin Burke 925.271.7005 | kev.inburke.com

bradfitz commented 8 years ago

Just one for now. Once a non-Googler touches other files they can update it.

kevinburke commented 8 years ago

Done

hblanks commented 7 years ago

Looks like you still have that data race to fix, @kevinburke :-)

kevinburke commented 7 years ago

Yikes. I think I forgot to push my branch months ago when I left this comment. Let me double check

On Thu, Dec 22, 2016 at 07:28 Hunter Blanks notifications@github.com wrote:

Looks like you still have that data race to fix, @kevinburke https://github.com/kevinburke :-)

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/golang/groupcache/pull/73#issuecomment-268822705, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOSI6xQFVCqigIGlirJsqVwTgCfC0r-ks5rKpcOgaJpZM4KeD5v .

kevinburke commented 6 years ago

Apologies for the delay, but I've finally made the changes you requested.