Apologies in advance. I'm new to Curator, and this is my first time posting
a question.

We recently upgraded to Curator 5.7.0 in our product. Some of the classes
in Curator, like PathChildrenCache, are now deprecated and must be
replaced. The docs I've found say to replace it with CuratorCache, but I
haven't found any guidelines on how to do that. I managed to come up with
this:

Old:

PathChildrenCache cache = new PathChildrenCache(client, path, true);
PathChildrenCacheListener listener = (client, event) -> {
    <handling code>
};
cache.getListenable().addListener(listener);


New:

CuratorCache cache = CuratorCache.builder(client, path)
    .build();
PathChildrenCacheListener listener = (client, event) -> {
    <handling code>
};
CuratorCacheListener ccListener = CuratorCacheListener.builder()
    .forPathChildrenCache(path, client, listener)
    .build();
cache.listenable().addListener(ccListener);


Is this the right way to do it?

Reply via email to