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

Use c.loader is ok ? why not c.reloader? #27

Closed yiting1122 closed 3 years ago

yiting1122 commented 3 years ago

image

because this is a loading cache ,c.loader is can not be nil. Thanks

yiting1122 commented 3 years ago

User may not set the reloader, i think use a flag is better way, when user set refreshAfterWrite the flag is true. of course, if user not set the refreshAfterWrite i think must return nil

nqv commented 3 years ago

loader is different to reloader. The former is required for a LoadingCache but not in a normal Cache. The latter is optional and only for LoadingCache, along with loader when applications want their own reloading strategy.

yiting1122 commented 3 years ago

if the reloader is not set , when the key expired, return the old value or return nil and delete the old value i think it must return nil.

nqv commented 3 years ago

I believe a LoadingCache would never return nil (empty value). It should either return old value or blocking to get new value.

nqv commented 3 years ago

See also https://github.com/goburrow/cache/issues/13