Skip to content

v0.6.0

Latest

Choose a tag to compare

@bnkamalesh bnkamalesh released this 13 Nov 17:52
· 1 commit to main since this release
94da985

Pocache v0.6.0 makes Payload.ExpireAt a plain time.Time instead of an atomic pointer. This is a small breaking change, only for code that builds or reads Payload.ExpireAt directly.

Breaking

  • Payload.ExpireAt is now a time.Time, not *atomic.Pointer[time.Time]. A Payload is created by Add and never modified after it is handed to the store, so the atomic protected nothing. Value() and Expiry() are unchanged.
  • Affected: custom Store implementations that build a Payload{ExpireAt: ...} or call ExpireAt.Load(), typically stores which serialise entries. Not affected: Get, Add, BulkAdd, and stores which keep the *Payload as is, like the sync.Map store in the README.

Changed

  • A zero ExpireAt, e.g. from a custom store which dropped the timestamp, is treated as expired. Previously a nil ExpireAt made Get panic.
  • Add is about 16% faster and allocates once instead of three times (77.9 ns, 56 B, 3 allocs to 65.4 ns, 48 B, 1 alloc). Get is about 1.7% faster. Measured with go test -bench . -benchmem -count=10 and benchstat.

Upgrade

// before
p := &pocache.Payload[string]{ExpireAt: ptr, Payload: v}
t := p.ExpireAt.Load()

// after
p := &pocache.Payload[string]{ExpireAt: t, Payload: v}
t := p.ExpireAt // or p.Expiry()
go get github.com/naughtygopher/pocache@v0.6.0

Full changelog: v0.5.0...v0.6.0