How to check local cache is up to date
Closed this issue · 2 comments
halfcrazy commented
At startup time, the program monitors tables and then queries some data, but the data may not be synced from the remote database.
Is there any way to check if the local cache is updated, like kubernetes informer hasSynced.
Edit: add kubernetes pattern
podsSynced := podInformer.Informer().HasSynced
cacheSyncs := []cache.InformerSynced{podsSynced }
if ok := cache.WaitForCacheSync(stopCh, cacheSyncs...); !ok {
klog.Fatalf("failed to wait for caches to sync")
}
// do staff
trozet commented
checkout waitForCacheConsistent:
Line 1253 in 3f40c8a
Delays reads until all updates have been processed.
halfcrazy commented
Thanks