Skip to content

v0.5.0

Choose a tag to compare

@bnkamalesh bnkamalesh released this 13 Nov 17:33
· 2 commits to main since this release
abea348

Pocache v0.5.0 moves background refreshes onto nibbler and reworks BulkUpdater. This release has breaking changes for BulkUpdater users.

Breaking

  • BulkUpdater now returns (map[K]T, error) instead of []UpdateResult[T], and UpdateResult is removed. There is no ordering contract to maintain: keys missing from the map keep their value and are retried by a later read, and keys in the map that were not requested are ignored. Values returned alongside an error are still stored, and the error is reported to ErrWatcher wrapped in ErrBulkUpdate.
  • Setting both Updater and BulkUpdater now fails New with ErrValidation. Previously BulkUpdater was silently never run.
  • Get no longer blocks when the update or deletion queue is full. The refresh or removal is skipped and a later read retries it. Raise QLength if reads outpace your updater.

Added

  • BulkSize (default 100) and BulkMaxWait (default 15ms) control the maximum batch size and the longest a key waits before a partial batch is sent.
  • ErrBulkUpdate sentinel error.

Changed

  • Updater and BulkUpdater both run on nibbler v0.3.1, replacing the inline batching loop. Close still cancels active updates and waits for the workers to exit.
  • Panics in either updater are recovered and reported as ErrPanic, and the keys of the failed update become eligible again.
  • Keys are released after their value is stored, in both update paths.
  • The module now depends on github.com/naughtygopher/nibbler, and test dependency testify moves to v1.12.1.

Upgrade

// before
BulkUpdater: func(ctx context.Context, keys []string) []pocache.UpdateResult[string] { ... }

// after
BulkUpdater: func(ctx context.Context, keys []string) (map[string]string, error) { ... }
go get github.com/naughtygopher/pocache@v0.5.0

Requires Go 1.26 or newer. The keys slice passed to BulkUpdater is reused after the call returns, so copy it if you need to keep it.

Full changelog: v0.4.0...v0.5.0