Removing Object from Cache in Three Lines
Call method Cache.remove() to remove an object from the cache:
Cacheonix cacheonix = Cacheonix.getInstance(); Cache<String, String> cache = cacheonix.getCache("my.cache"); String removedValue = cache.remove("my.key");
Removing Collection of Objects from Cache
Cacheonix provides method Cache.removeAll() that allows to remove a set of keys from the cache:
// Get cache Cacheonix cacheonix = Cacheonix.getInstance(); Cache<String, String> cache= cacheonix.getCache("my.cache"); // Create a key set final Set<String> keySet = new HashSet(2); keySet.add("my.key.0"); keySet.add("my.key.0"); // Remove keys boolean modified = cache.removeAll(keySet);
See also:
Labels
(None)
