Hi,
I have an application which use Spring 3.1.0.M1 and cache abstraction using ehcache and @Cacheable annotation.
I configured my cache as :
I have two classes LdapProxyManager and LdapManager. When I call LdapProxyManager.findFromDn(myDn) for the first times, it is working, and the object is put in the cache.Code:<cache name="ldap_cache" maxElementsInMemory="10000" eternal="false" overflowToDisk="false" timeToIdleSeconds="120" timeToLiveSeconds="480" />
When I call another time the LdapProxyManager.findFromDn(myDn), the results of the LdapManager.findFromDn(myDn) are taken from the cache.
Now I wait for a while... wait for the element in cache to be expired...
I call the LdapProxyManager.findFromDn(myDn), he results of the LdapManager.findFromDn(myDn) are taken from the cache, but it return null.
What can I do in order the result not to be taken from the cache when expired ?
Code:public class LdapProxyManagerImpl implements LdapProxyManager { @Autowired LdapManager ldapMgr; @Override public BaseEntity findFromDn(String dn) { return ldapMgr.findFromDn(dn); } }Code:public class LdapManagerImpl implements LdapManager { private static final String CACHE_NAME = "ldap_cache"; private LdapProvider ldap; @Override @Cacheable(CACHE_NAME) public BaseEntity findFromDn(String dn) { try { logger.debug("findFromDn(" + dn + ")"); return ldap.findFromDn(dn); } catch (Exception e) { return null; } } }


Reply With Quote
