We are planning to use ristretto cache in kyverno. Can anyone tell me what are the uses of the ristretto cache wait() function?? In what scenerios we should use wait() function ??
Are you speaking of this function in cache.go
?
// Wait blocks until all buffered writes have been applied. This ensures a call to Set()
// will be visible to future calls to Get().
func (c *Cache) Wait() {
if c == nil || c.isClosed {
return
}
wg := &sync.WaitGroup{}
wg.Add(1)
c.setBuf <- &Item{wg: wg}
wg.Wait()
}
If the comment isn’t clear enough, you can see from a search of that func that it’s used commonly in tests to wait until all asynchronous operations on the cache are completed. Not normally needed, but seems to be sort of a manual override to Ristretto’s normal operation.