ovn-org/libovsdb

How to check local cache is up to date

Closed this issue · 2 comments

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

checkout waitForCacheConsistent:

func waitForCacheConsistent(ctx context.Context, db *database, logger *logr.Logger, dbName string) {

Delays reads until all updates have been processed.

Thanks