xyuanlu commented on code in PR #2619:
URL: https://github.com/apache/helix/pull/2619#discussion_r1336195262
##########
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClientCache.java:
##########
@@ -56,19 +58,39 @@ public ZkMetaClientCache(ZkMetaClientConfig config,
MetaClientCacheConfig cacheC
super(config);
_cacheClient = getZkClient();
_rootEntry = cacheConfig.getRootEntry();
- _lazyCaching = cacheConfig.getLazyCaching();
_cacheData = cacheConfig.getCacheData();
_cacheChildren = cacheConfig.getCacheChildren();
+
+ if (_cacheData) {
+ _dataCacheMap = new ConcurrentHashMap<>();
+ }
+ if (_cacheChildren) {
+ _childrenCacheTree = new TrieNode(_rootEntry, null);
+ }
}
+ /**
+ * Get data for a given key.
+ * If datacache is enabled, will fetch for cache. If it doesn't exist
+ * returns null (for when initial populating cache is in progress).
+ * @param key key to identify the entry
+ * @return data for the key
+ */
@Override
- public Stat exists(String key) {
- throw new MetaClientException("Not implemented yet.");
+ public T get(final String key) {
+ if (_cacheData) {
+ return getDataCacheMap().get(key);
+ }
+ return _cacheClient.readData(key, true);
Review Comment:
Should we do raw zk client read or super.readData()?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]