PSA: You can also use singleflight[1] to solve the problem. This prevents the thundering herd problem. Pocache is an interesting/alternative way to solve thundering herd indeed! [1]: https://pkg.go.dev/golang.org/x/sync/singleflight
Show HN: Pocache, preemptive optimistic caching for Go
11–20 of 33 posts
Re: Show HN: Pocache, preemptive optimistic caching for Go
#12Re: Show HN: Pocache, preemptive optimistic caching for Go
#13Re: Show HN: Pocache, preemptive optimistic caching for Go
#14You may be interested in Groupcache's method for filling caches, it solves the same problem that I believe this project is aimed at. Groupcache has a similar goal of limiting the number of fetches required to fill a cache key to one—regardless of the number of concurrent requests for that key—but it doesn't try to speculatively fetch data, it just coordinates fetching so that all the routines attempting to query the…
Re: Show HN: Pocache, preemptive optimistic caching for Go
#15You may be interested in Groupcache's method for filling caches, it solves the same problem that I believe this project is aimed at. Groupcache has a similar goal of limiting the number of fetches required to fill a cache key to one—regardless of the number of concurrent requests for that key—but it doesn't try to speculatively fetch data, it just coordinates fetching so that all the routines attempting to query the…
It's using singleflight which was later on added to the Go std lib: https://github.com/golang/groupcache/tree/master/singlefligh... https://pkg.go.dev/golang.org/x/sync/singleflight
Re: Show HN: Pocache, preemptive optimistic caching for Go
#16Earlier quoted context omitted.
> if I initially got the key "foo" at time T=00:00:00, this library would re-query the backing system until time T=00:00:60? even if I requery it at T=:01? From what I understood of the README (10 minute expiry, 1 minute window) only cache requests between 09:00 to 09:59 will trigger a pre-emptive backing fetch. ie. T0-539 seconds uses the first query (no re-fetch), T540-599 does a pre-emptive re-fetch (as long as no…
@zimpenfish yes you are right. refetch is initiated on the first Get between 9-10mins, and the timer is reset as soon as the back fetch is successful
[1] https://github.com/ben-manes/caffeine/tree/master/examples/c...
Re: Show HN: Pocache, preemptive optimistic caching for Go
#17You may be interested in Groupcache's method for filling caches, it solves the same problem that I believe this project is aimed at. Groupcache has a similar goal of limiting the number of fetches required to fill a cache key to one—regardless of the number of concurrent requests for that key—but it doesn't try to speculatively fetch data, it just coordinates fetching so that all the routines attempting to query the…
Is groupcache suitable for current use? I don't see commits in years and the issues have reports of panics due to bugs.
[1]: https://github.com/golang/groupcache/issues/158#issuecomment...
Re: Show HN: Pocache, preemptive optimistic caching for Go
#18I have implemented my own SIEVE cache, with TTL support. It solves all these issues and requires no background workers. Author, or anyone else interested in this, should read the SIEVE paper/website and implement their own.
Re: Show HN: Pocache, preemptive optimistic caching for Go
#19Not work
Re: Show HN: Pocache, preemptive optimistic caching for Go
#20PSA: You can also use singleflight[1] to solve the problem. This prevents the thundering herd problem. Pocache is an interesting/alternative way to solve thundering herd indeed! [1]: https://pkg.go.dev/golang.org/x/sync/singleflight
I'm confused by the decision in DoChan to return a channel (instead of accepting one supplied by the caller) and then, given that, also not to close that channel (is something else going to be sent to the channel in the future?). Both seem like strange/unnecessary design decisions.
DoChan doesn't close the channel because there isn't any reason to do so.