Skip to content

v0.3.0

Choose a tag to compare

@andared andared released this 07 Sep 09:02
8c0a44f

Typed views now support loaders: concurrent misses for the same key through one View share a single upstream call while all value types continue to use the parent cache's byte budget.

  • Add ViewOptions.Loader and View.GetOrLoad, with typed results, per-view cost and TTLs, negative caching, cancellation and panic handling matching Cache.GetOrLoad.
  • Add ViewStats.Loads, LoadErrors and Coalesced, also included in parent-cache statistics.
  • Add runnable basic-cache and HTTP-loader examples, an executable view-loader example, and updated getting-started documentation.

Reuse one View instance to share in-flight work. Loaders receive unprefixed keys; separate view instances and the parent cache have independent loaders. A view without its own loader returns ErrNoLoader.

Compatibility: ViewOptions and ViewStats gained fields. Replace positional struct literals with named fields. Go 1.24 remains the minimum; the library has no dependencies.

Install:

go get github.com/andared/sanecache@v0.3.0

Full changelog: v0.2.0...v0.3.0