/**
* Called immediately after an element is <i>found</i> to be expired. The
* {@link net.sf.ehcache.Cache#remove(Object)} method will block until this method returns.
* <p/>
* As the {@link Element} has been expired, only what was the key of the element is known.
* <p/>
* Elements are checked for expiry in ehcache at the following times:
* <ul>
* <li>When a get request is made
* <li>When an element is spooled to the diskStore in accordance with a MemoryStore
* eviction policy
* <li>In the DiskStore when the expiry thread runs, which by default is
* {@link net.sf.ehcache.Cache#DEFAULT_EXPIRY_THREAD_INTERVAL_SECONDS}
* </ul>
* If an element is found to be expired, it is deleted and this method is notified.
*
* @param cache the cache emitting the notification
* @param element the element that has just expired
* <p/>
* Deadlock Warning: expiry will often come from the <code>DiskStore</code>
* expiry thread. It holds a lock to the DiskStorea the time the
* notification is sent. If the implementation of this method calls into a
* synchronized <code>Cache</code> method and that subsequently calls into
* DiskStore a deadlock will result. Accordingly implementers of this method
* should not call back into Cache.
*/
void notifyElementExpired(final Ehcache cache, final Element element);
以上是 Ehcache notifyElementExpired 接口的说明,看来触发条件有2个
1、When a get request is made
2、When an element is spooled to the diskStore in accordance with a MemoryStore
我试过了,但是notifyElementExpired 这个方法在对象过期时并没有被调用,而是在获取这个对象时调用了。难道不框架在对象过期时不能主动通知我吗?
我试过了,但是notifyElementExpired 这个方法在对象过期时并没有被调用,而是在下次获取这个对象时调用了。难道不框架在对象过期时不能主动通知我吗???
谁有解决办法没有?
以上是 Ehcache notifyElementExpired 接口的说明,看来触发条件有2个
1、When a get request is made
2、When an element is spooled to the diskStore in accordance with a MemoryStore
eviction policy
请问第二个是什么意思? 怎么配置能满足第二条,让题目所示需求能够满足?
没办法,自己做了一个quartz ,每隔 30S 主动调用一下检查。