Closed yolossn closed 1 year ago
I have also encountered this problem. May I ask how to solve it?
func main() {
ristrettoCache, err := ristretto.NewCache(&ristretto.Config{
NumCounters: 1000,
MaxCost: 100,
BufferItems: 64,
})
if err != nil {
panic(err)
}
ristrettoStore := ristretto_store.NewRistretto(ristrettoCache)
ch := cache.New[string](ristrettoStore)
err = ch.Set(context.Background(), "test", "value")
if err != nil {
panic(fmt.Sprintf("err in set:%+v\n", err))
}
ristrettoCache.Wait()
value, err := ch.Get(context.Background(), "test")
if err != nil {
panic(fmt.Sprintf("err in get:%+v\n", err))
}
fmt.Println("The value is ", value)
}
ristrettoCache.Wait()
is the key
Closing this issue as there is no issue with the Gocache library.
Maybe we could add an option to the Gocache's store configuration to automatically call Wait
after each Set()
?
Please feel free to open a pull request if you want to or reopen this issue if you still have any issue!
Thank you
Simply setting a value and getting it fails when using ristretto store.
Steps for Reproduction
Expected behavior: Expected the value to be printed
Actual behavior: Getting an error "value not found in store"
Platforms: Windows WSL
Extras: I think the error is happening because ristretto expects to wait after a key is set, but the ristretto store implementation doesn't do that. Refer this example where the
Wait()
function is used afterSet()
for the value to pass through buffers. https://github.com/dgraph-io/ristretto#Example