Skip to content
/ wcache Public

In-memory cache with write-back strategy. DO NOT USE, it's very slow.

License

Notifications You must be signed in to change notification settings

vtopc/wcache

Repository files navigation

wcache

License Godoc Reference

Implements in-memory cache with write-back strategy (a cache with expiration). An expiration callback(expireFn) will be called when record is expired.

Features

  • 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.

Install

go get github.com/vtopc/wcache

TODO

  • Optional auto-extending expiration on Get and/or Set.

Similar projects