ttlcache
ttlcache copied to clipboard
Add Version method to item type
It should return a uint64
that determines how many times an item has been updated. This method may be useful in situations when a task's execution depends on whether the item has changed or not and when due to the duration of another task a transaction/mutex isn't acceptible.
item := cache.Get("key")
version := item.Version()
// long task
if item.Version() == version {
// execute only if the item hasn't been updated during the long task's execution
}
Alternatively, this can also be part of the object being put into the cache now that we have generics support.