Implements in-memory cache with write-back strategy
(a cache with expiration).
An expiration callback(expireFn
) will be called when record is expired.
- Thread-safe.
- Per-key or global TTL.
- Can trigger a custom callback on key expiration(could be used as Pub/Sub with aggregation).
- Can trigger a custom callback on key collisions(e.g. for aggregating metrics). By default, will overwrite value.
- Graceful shutdown(using context). Will call expiration callback for all records, ignoring they TTL.
go get github.com/vtopc/wcache
- Optional auto-extending expiration on
Get
and/orSet
.