I would like to use the Search API of EhCache 2.8 to invalidate (remove) a
group of cache entries from cache. In my cache different types of
elements and therefor keys are stored. Products, Items, Badges and more.
How do I have to define the search attributes in ehcache.xml? I tried
one attribute with expression like "key.getProductId()". But putting the
first
non product element on the cache results into:
net.sf.ehcache.search.attribute.AttributeExtractorException: No such method named "getProductId" present on instance of class ...
How can I solve this problem? Do I have to define a separate cache for each type of element??
Here is a part of my configuration and code:
<searchable keys="true" values="false">
<searchAttribute name="productId" expression="key.getProductId()" type="Long"/>
</searchable>
Query query = getCache().createQuery().addCriteria(getCache().getSearchAttribute("productId").eq(id)).includeKeys().end();