public static KVCache newCache( final KeyValueClient kvClient, final String rootPath, final int watchSeconds, final QueryOptions queryOptions) { final String keyPath = prepareRootPath(rootPath); final Function<Value, String> keyExtractor = getKeyExtractorFunction(keyPath); final ConsulCache.CallbackConsumer<Value> callbackConsumer = (index, callback) -> { QueryOptions params = watchParams(index, watchSeconds, queryOptions); kvClient.getValues(keyPath, params, callback); }; CacheDescriptor cacheDescriptor = new CacheDescriptor("keyvalue", rootPath); return new KVCache(keyExtractor, callbackConsumer, kvClient.getConfig().getCacheConfig(), kvClient.getEventHandler(), cacheDescriptor); }