-
Notifications
You must be signed in to change notification settings - Fork 48
JCacheConfiguration ignores eternal flag if configured using ehcache.xml #40
Comments
Looks like this was introduced when fixing #26 |
@tarioch You configure the |
Sure I have an ehcache.xml and then do
to retrieve the cache. This triggers JCacheManager.refreshAllCaches() which does
which then ends up in the failing code block. |
Oh ok... so the issue is what the |
The issue I noticed is that, JCache.getValue() starts triggering a remove as it is actually reading this generated JCache config. |
@tarioch I'll try to put a test case together to reproduce this... I seem to see we'll expose the TTI & TTL values, but these may well be set in your config (along with the eternal flag), so that these get picked up, rather than them being 0? |
Line 843-846 in public final void setEternal(boolean eternal) {
checkDynamicChange();
isEternalValueConflictingWithTTIOrTTL(eternal, getTimeToLiveSeconds(), getTimeToIdleSeconds());
this.eternal = eternal;
if (eternal) {
setTimeToIdleSeconds(0);
setTimeToLiveSeconds(0);
}
} If Line 93-108 in expiryPolicy = new ExpiryPolicy() {
@Override
public Duration getExpiryForCreation() {
return new Duration(TimeUnit.SECONDS, cacheConfiguration.getTimeToLiveSeconds());
}
@Override
public Duration getExpiryForAccess() {
return new Duration(TimeUnit.SECONDS, cacheConfiguration.getTimeToLiveSeconds());
}
@Override
public Duration getExpiryForUpdate() {
return getExpiryForCreation();
}
}; If Line 138-141 in private Element getElement(final K key) {
final Element element = ehcache.get(key);
if (element == null)
return null;
final Duration expiryForUpdate = cfg.getExpiryPolicy().getExpiryForAccess();
if(expiryForUpdate != null && expiryForUpdate.isZero()) {
ehcache.removeElement(element);
}
return element;
} If the Add these codes in if(cacheConfiguration.isEternal()){
expiryPolicyFactory = EternalExpiryPolicy.factoryOf();
expiryPolicy = expiryPolicyFactory.create();
}else{
expiryPolicyFactory = null;
expiryPolicy = new ExpiryPolicy(){
//...
}
} |
Any reason this has not been fixed? The change is pretty simple, and presently its not possible to configure an eternal cache via ehcache.xml because of this. Unsure about the
|
commit 30aa0f1 Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 21:38:01 2015 -0700 Remove shiro-ehcache, its no longer used commit 355d5b1 Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 19:46:52 2015 -0700 Tidy api commit e60f740 Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 19:44:27 2015 -0700 Add some more tests, but have to disable due to ehcache/ehcache-jcache#40 commit ce44f7d Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 19:41:13 2015 -0700 Add commented shiro-activeSessionCache config, with notes why we can not enable this atm due to bug in ehcache-jcache impl commit baf920b Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 19:36:58 2015 -0700 Simplify shiro jcache adapter, add some logging commit 9c7ab27 Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 18:53:39 2015 -0700 Fix exclude commit de22ee4 Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 15:49:17 2015 -0700 Replace ehcache CacheManager.shutdown() with jcache CacheManager.close() commit b92b3f3 Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 15:18:50 2015 -0700 notes commit 85668db Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 14:34:17 2015 -0700 note to use Externalizable commit c7f903c Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 14:21:11 2015 -0700 Move to internal package nothing should be referencing this directly, a bit more tidy. commit 70e0000 Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 14:20:29 2015 -0700 Make JCache key and values Serializable, likely will want to make these Externalize instead though to optimize commit 0ccb87b Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 13:57:44 2015 -0700 tidy commit ff4aa29 Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 13:51:43 2015 -0700 Minor tidy and text update commit 27130d3 Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 13:39:26 2015 -0700 tidy sync, no needed atm update license headers commit 263ca70 Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 13:30:24 2015 -0700 failsafe -> default to avoid confusing with ehcache's own failsafe config commit 044c78e Author: Jason Dillon <jason@planet57.com> Date: Sat Jul 25 13:28:08 2015 -0700 Bring back ehcache-failsafe.xml configuration
Sorry for noise above, sometimes github linking is a bit of PITA |
Sorry, my bad. Remained assigned to me, but I was off on vacation. Back now though. |
Ah the project is alive.. yay. Will sent over signed legal mumbo jumbo shortly. |
Cool! Thanks... Now, that being said, the project is slow moving though. I have to be honest with you: all our efforts are going into Ehcache3, this wrapper was a temporary solution for 2.x users. But all (including features that were only "proprietary" ones in the 2.x line, e.g. Offheap) go into the new dev line. Here: https://github.com/ehcache/ehcache3 |
@alexsnaps understood, and we'll consume ehcache3 once it stabilizes, but until then we are moving to use javax.cache api to allow us to switch the backend, so having the adapter for ehcache2 is helping us move forward while ehcache3 becomes more realistic for usage. |
As far as I'm able to tell, if I configure the cache with an ehcache.xml and have set the cache to be eternal, this is getting ignored as the constructor of JCacheConfiguration always sets up an expiry policy.
The text was updated successfully, but these errors were encountered: