Repository navigation
v0.8.0
Hot keys that stay warm, costs that come with the value, and increments for exporters
Options.RefreshAfter and ViewOptions.RefreshAfter. A read that finds a value older than this returns it at once and reloads it in the background, so a key in steady use is replaced before it expires instead of making the next caller wait for the upstream. Each value gets one refresh, shared with the key's other loads, and invalidation keeps a stale result out. The TTL still holds: a failed refresh is not retried, and the value lives out its TTL. GetOrLoad, GetManyOrLoad and GetOrLoadFunc refresh with their loaders, Get and Lookup with the ones in Options; GetManyOrLoad refreshes its due keys in one BatchLoader call. Off by default. Counted in the new Refreshes and RefreshErrors, apart from Loads.
SetWithCost and GetOrLoadFuncWithCost on Cache and View take the value's cost along with it, for values whose size is known only where they are produced, such as the response they were decoded from.
Stats.Sub and ViewStats.Sub return the counters gained since a previous snapshot, which is what a statsd exporter sends each interval.
The doc comments and the README are shorter, and the GetOrLoadFunc and GetManyOrLoad examples on pkg.go.dev no longer carry each other's descriptions.
Stats and ViewStats gained fields: code that builds them positionally needs updating. See CHANGELOG.md.
Install:
go get github.com/andared/sanecache@v0.8.0