Repository navigation
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.ExpireAtis now atime.Time, not*atomic.Pointer[time.Time]. APayloadis created byAddand never modified after it is handed to the store, so the atomic protected nothing.Value()andExpiry()are unchanged.- Affected: custom
Storeimplementations that build aPayload{ExpireAt: ...}or callExpireAt.Load(), typically stores which serialise entries. Not affected:Get,Add,BulkAdd, and stores which keep the*Payloadas is, like thesync.Mapstore in the README.
Changed
- A zero
ExpireAt, e.g. from a custom store which dropped the timestamp, is treated as expired. Previously a nilExpireAtmadeGetpanic. Addis 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).Getis about 1.7% faster. Measured withgo test -bench . -benchmem -count=10andbenchstat.
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.0Full changelog: v0.5.0...v0.6.0