Wednesday, June 17, 2009

Tricks with CacheFactory

Coherence's com.tangosol.net.CacheFactory is one of the most powerful tools available that provides a console input to the data grid. The CacheFactory can be used to initialize new caches, insert, delete or update data and can also be used to find the size of the cache and if a cache contains a certain key or not. CacheFactory console uses Java reflection to invoke methods. Typing help displays all the commands that can be executed. Some are pretty obvious like put, get, size, cache <cache_name> etc. But there are a lot that are hidden and are not so obvious. Following are some useful commands that can be executed:
&keySet To return a set of all the keys in the cache
&containsKey 1 Returns true or false if the Cache contains a key = 1
filter EQ1 Equals toString MyValue Creates an EqualsFilter
list <cache_name> EQ1Returns a set of values whose toString on the Cache Entry is equal to MyValue

And the fanciest of all (execute it after initializing a cache):
&getNamedCache.
getCacheService.
getBackingMapManager.
getCacheFactory.getConfig
Prints the cache configuration currently loaded by this node.
&getNamedCache.
getCacheService.
getBackingMapManager.
getCacheFactory.getConfig.
findElement /caching-schemes/proxy-scheme

Prints the proxy-scheme XmlElement defined in the cache configuration currently loaded by this node.
invoke:Management "#1 cache foo; &getCacheService.getService.getStorage bar" To find the internal storage on node 1 from the cache foo to the cache bar with the same service
Enjoy!

Wednesday, June 10, 2009

Windows Ad

We don't price ourselves to be just different. Its a smart investment in your future.