My 2 cents: I'd rather keep the API clean, at the expense of folks
potentially writing wrapping code (like Ben).
Your code samples look a bit weird:
#1
Why do you always get the child ? Can't you get the node and cache it, e.g.
Node n=cache.getRoot().getChild(fqn);
n.containsKey(PojoInstance.KEY)
#2
Same as for #1: you don't need to call cache.getRoot().getChild(fqn) all
the time, for example in a loop, simply cache it
Ben Wang wrote:
Manik,
While trying to use the new API in PojoCache, I have found that I need to:
1. To check if a attribute exist, I need to do:
cache_.getRoot().getChild(fqn_).getData().values().contains(PojoInstance.KEY)
2. And then, I need to do a lot of cache_.getRoot().getChild(fqn).put(map)
So looks like I need to write a wrapper layer just to provide straight
api for:
Cache_.exists(fqn, key)
And
Cache_.put(fqn, map)
If this is rare case, then I will bite the bullet. But if it is a
common one, then that really begs the question whether we should
provide additional apis or not?
--
Bela Ban
Lead JGroups / Manager JBoss Clustering Group
JBoss - a division of Red Hat