Skip to content

v0.4.0

Choose a tag to compare

@bnkamalesh bnkamalesh released this 13 Sep 18:24
3df73d1

Pocache v0.4.0 adds bulk refreshes and explicit cache shutdown. It requires Go 1.26 or newer, up from Go 1.22 in v0.3.2.

Changes

  • Added Cache.Close() to cancel active updater contexts, stop background workers, and wait for them to exit. Repeated and concurrent calls are safe.
  • Added BulkUpdater, UpdateResult, Tuple, and BulkAdd for batch refreshes and writes.
  • Fixed concurrent update debouncing and unnecessary splitting of queued bulk refreshes.
  • Moved timing tests to testing/synctest, added shutdown race coverage and benchmarks, and enabled modernization lint. Uncached race-test wall time dropped from about 32s to 1.6s locally.

Upgrade

With GOTOOLCHAIN=local, install Go 1.26 or newer first. The default GOTOOLCHAIN=auto can select a newer toolchain.

go get github.com/naughtygopher/pocache@v0.4.0

Reuse a cache across requests and call Close() when its owner shuts down. Close abandons queued work and retains the store. After shutdown begins, reads miss and writes are no-ops; calls already in progress may finish.

Updaters must honor context cancellation, and store methods and error watchers must return for shutdown to complete. Callbacks must not synchronously call Close() on their own cache.

For a service, construct one cache at startup, share it across handlers, stop the handlers during shutdown, then close the cache.

Verification

Build, vet, race tests, lint, and the aggregate build check passed on the release commit. Compatibility was verified on Go 1.26.7 and 1.27.1.

Full changelog: v0.3.2...v0.4.0