goburrow / cache

Mango Cache 🥭 - Partial implementation of Guava Cache in Go (golang).
BSD 3-Clause "New" or "Revised" License
580 stars 48 forks source link

[Feature request]defaults to old values when `LoaderFunc` failed #12

Closed qudongfang closed 4 years ago

qudongfang commented 5 years ago

Feature request

Would you please consider adding a new option to support this? Get defaults to old values when LoaderFunc returns an error in LoadingCache.

qudongfang commented 5 years ago

I found some information in Guava Cache wiki about Refresh says that:

If an exception is thrown while refreshing, the old value is kept, and the exception is logged and swallowed.

While it behaves differently in this project. https://github.com/goburrow/cache/blob/576a8d1542c8e8c497af31460ff7acc669a6fa51/local.go#L149-L170

nqv commented 4 years ago

I believe this is fixed in https://github.com/goburrow/cache/commit/ed586e32006b30416a68137394a5f27d374c6eb0