The only workaround I can see is to create another Cache instance with the goal to store under a known key an object containing keys, or any more complex structure.
This structure is modified in the onPut() and onRemove() methods of the used CacheListener:
public void onRemove(Object key)
{
LOG.log(Level.INFO, key.toString());
Map<Integer, Date> realEstateIdByDate = (Map<Integer, Date>) keyCache.get("realEstateIdByDate");
realEstateIdByDate.remove(key);
keyCache.put("realEstateIdByDate", realEstateIdByDate);
}
@Override
public void onPut(Object object)
{
LOG.log(Level.INFO, object.toString());
Map<Integer, Date> realEstateIdByDate = (Map<Integer, Date>) keyCache.get("realEstateIdByDate");
realEstateIdByDate.put(((RealEstateAd)object).getRealEstateId(), new Date());
keyCache.put("realEstateIdByDate", realEstateIdByDate);
}
Any feedback more than welcome ;-)