Repository navigation
v0.5.0
Pocache v0.5.0 moves background refreshes onto nibbler and reworks BulkUpdater. This release has breaking changes for BulkUpdater users.
Breaking
BulkUpdaternow returns(map[K]T, error)instead of[]UpdateResult[T], andUpdateResultis 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 toErrWatcherwrapped inErrBulkUpdate.- Setting both
UpdaterandBulkUpdaternow failsNewwithErrValidation. PreviouslyBulkUpdaterwas silently never run. Getno longer blocks when the update or deletion queue is full. The refresh or removal is skipped and a later read retries it. RaiseQLengthif reads outpace your updater.
Added
BulkSize(default 100) andBulkMaxWait(default 15ms) control the maximum batch size and the longest a key waits before a partial batch is sent.ErrBulkUpdatesentinel error.
Changed
UpdaterandBulkUpdaterboth run on nibbler v0.3.1, replacing the inline batching loop.Closestill 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.0Requires 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