Cache destroy and removing objects based on filter
780607Jan 20 2011 — edited Jan 24 2011Hi,
I have lined up a few questions to understand the ways we can destroy/remove cache entries or cache itself on a collective basis and not just the cache.remove(key).
1. How do I remove a group of keys from the cache? Say either I know the keySet or a keySet obtained based on a filter. I can see the Java doc says namedCache also implements queryMap and that supports keySet(Filter) but unlike Map.keySet(), the set returned by this method may not be backed by the map, so changed to the set may not be reflected in the map.
http://download.oracle.com/otn_hosted_doc/coherence/353/com/tangosol/util/QueryMap.html#keySet(com.tangosol.util.Filter)
Now that also means cache.keySet().removeAll() may not work. Can we confirm that, as another article http://wiki.tangosol.com/display/COH35UG/Data+Affinity shows an example way to use entryset or keyset and shows this line:
cacheLineItems.keySet().removeAll(setLineItemKeys).
2. Is namedcache.destroy() a blocking or non-blocking? Coz in one of our tests, we created a for loop of the following code:
a. create cache.
b. use cache.
c. destroy cache.
And we expected at any point of time to have only one cache to be active on the cluster, however with the 500M as the high unit, we never saw evictions and indeed saw out of memory error. We had like 100 iterations. We expected destroy cache to basically delete the cache, thereby freeing the memory on the JVM. We only had one proxy and one storage in our test.
3. Is namedcache.clear() a blocking or non-blocking call? Although this does not necessarily removes the cache, it only unmaps all the entries in the cache.