tidwall / buntdb

BuntDB is an embeddable, in-memory key/value database for Go with custom indexing and geospatial support
MIT License
4.57k stars 289 forks source link

Adding OnExpiredSync Callback #34

Closed dc0d closed 6 years ago

dc0d commented 6 years ago

OnExpiredSync callback is added to Config - #32 .

OnExpiredSync will be called inside the same transaction that is performing the deletion of expired items. If OnExpired is present then this callback will not be called. If this callback is present, then the deletion of the timeed-out item is the explicit responsibility of this callback.

Optional boolean parameter ignoreExpired added to *Tx.Get(key string, ignoreExpired ...bool) to see the item even if it's expired. It does not break the API. This option is useful in sliding timeout scenarios.

Get returns a value for a key. If the item does not exist or if the item has expired then ErrNotFound is returned. If ignoreExpired is true, then the found value will be returned even if it is expired.