You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by hwaastad <he...@waastad.org> on 2015/01/23 14:02:32 UTC
tomee jcache question
Hi,
got a question regarding tomee/jcs/jcache
@Produces
@WebCache
@ApplicationScoped
public CacheManager createManager() {
System.out.println("Producing cache.......");
try {
URI uri =
this.getClass().getClassLoader().getResource("cache.ccf").toURI();
CachingProvider cachingProvider = Caching.getCachingProvider();
return cachingProvider.getCacheManager(uri,
Thread.currentThread().getContextClassLoader(),
cachingProvider.getDefaultProperties());
} catch (URISyntaxException ex) {
System.out.println("USING DEFAULT CACHE MANAGER.......");
return Caching.getCachingProvider().getCacheManager();
}
}
@Produces
@WebCacheType(CacheType.WEB)
@ApplicationScoped
public Cache createCache(@WebCache CacheManager manager) {
return manager.createCache(
"person_cache",
new MutableConfiguration()
.setStoreByValue(false)
.setStatisticsEnabled(true)
.setManagementEnabled(true)
.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(new
Duration(TimeUnit.SECONDS, 3600L))));
}
If I'm right, it will be evicted from cache if not accessed in an hour?
in tomee 1.7.1 right now its only in cache for a few milliseconds...
this is my cache.ccf:
jcs.default=DC
jcs.default.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=200001
jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
jcs.default.cacheattributes.UseMemoryShrinker=true
jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
jcs.default.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLife=700
jcs.default.elementattributes.IdleTime=1800
jcs.default.elementattributes.IsSpool=true
jcs.default.elementattributes.IsRemote=true
jcs.default.elementattributes.IsLateral=true
However, using
return Caching.getCachingProvider().getCacheManager();
in CM producer, it's working OK.
Am I doing something wrong here?
br hw
--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/tomee-jcache-question-tp4673495.html
Sent from the TomEE Users mailing list archive at Nabble.com.
Re: tomee jcache question
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Tomee 2 yes and jcs vote is still in progress
Le 24 janv. 2015 13:57, "hwaastad" <he...@waastad.org> a écrit :
> BTW,
> is JSr107 annotiations supported in tomee?
>
> And @Romain, another question,
> do you happen to know if jcache-jcs will become 2.0.0 anytime in the near
> future?
>
> br hw
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/tomee-jcache-question-tp4673495p4673515.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>
Re: tomee jcache question
Posted by hwaastad <he...@waastad.org>.
BTW,
is JSr107 annotiations supported in tomee?
And @Romain, another question,
do you happen to know if jcache-jcs will become 2.0.0 anytime in the near
future?
br hw
--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/tomee-jcache-question-tp4673495p4673515.html
Sent from the TomEE Users mailing list archive at Nabble.com.
Re: tomee jcache question
Posted by hwaastad <he...@waastad.org>.
OK,
understood that I could skip maxlife form cache.ccf which gives
MaxLifeSeconds = -1 and then it's more readable, at least for me programming
the cacheManager.
Anyway, thank a lot for clearifying this.
br hw
--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/tomee-jcache-question-tp4673495p4673503.html
Sent from the TomEE Users mailing list archive at Nabble.com.
Re: tomee jcache question
Posted by Romain Manni-Bucau <rm...@gmail.com>.
I was for removing all these logs but history history ;)
Using JCache MaxLife is auto computed so personally I use either fully
JCache or fully JCS but I do not mix both on eviction.
Default could surely be enhanced for sure. About the difference of
behavior without a sample to reproduce hard to say why but could be a
conflicting config file since it only uses classloader to find the
file?
Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau
2015-01-23 15:00 GMT+01:00 hwaastad <he...@waastad.org>:
> OK,
> INFO - setting defaultElementAttributes to [ IS_LATERAL = true, IS_SPOOL =
> true, IS_REMOTE = true, IS_ETERNAL = false, MaxLifeSeconds = 700, IdleTime =
> 1800, CreateTime = 1422021256290, LastAccessTime = 1422021256290,
> getTimeToLiveSeconds() = 699, createTime = 1422021256290 ]
>
> kind of hard reading "MaxLifeSeconds" as milliseconds ;-)
>
> So, what I should do is defining MaxLife > any expirepolicy I have?
>
> What is then actually happening if default settings is used?
> What confused me is that I belived the jcache.ccf in commons-jcs-jcache was
> used if creating a default CM. And those specs where the same as in my
> custom, and still working differently.
>
>
> br
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.n4.nabble.com/tomee-jcache-question-tp4673495p4673500.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
Re: tomee jcache question
Posted by hwaastad <he...@waastad.org>.
OK,
INFO - setting defaultElementAttributes to [ IS_LATERAL = true, IS_SPOOL =
true, IS_REMOTE = true, IS_ETERNAL = false, MaxLifeSeconds = 700, IdleTime =
1800, CreateTime = 1422021256290, LastAccessTime = 1422021256290,
getTimeToLiveSeconds() = 699, createTime = 1422021256290 ]
kind of hard reading "MaxLifeSeconds" as milliseconds ;-)
So, what I should do is defining MaxLife > any expirepolicy I have?
What is then actually happening if default settings is used?
What confused me is that I belived the jcache.ccf in commons-jcs-jcache was
used if creating a default CM. And those specs where the same as in my
custom, and still working differently.
br
--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/tomee-jcache-question-tp4673495p4673500.html
Sent from the TomEE Users mailing list archive at Nabble.com.
Re: tomee jcache question
Posted by Romain Manni-Bucau <rm...@gmail.com>.
only the timefactor (MaxAge * timeFactor => unit in millisecond). Its
default in jcs-core is 1000 but jcache forces 1 (just to get ms
granularity).
Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau
2015-01-23 14:40 GMT+01:00 hwaastad <he...@waastad.org>:
> Yeah,
>
> so what you are saying is that if I use a custom cache.ccf, jcs settings
> will override my application jcache settings?
>
> br hw
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.n4.nabble.com/tomee-jcache-question-tp4673495p4673497.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
Re: tomee jcache question
Posted by hwaastad <he...@waastad.org>.
Yeah,
so what you are saying is that if I use a custom cache.ccf, jcs settings
will override my application jcache settings?
br hw
--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/tomee-jcache-question-tp4673495p4673497.html
Sent from the TomEE Users mailing list archive at Nabble.com.
Re: tomee jcache question
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi
700ms for instance?
JCache module forces jcs times to be in ms and not in second (default
in jcs) to be able to respect the spec.
Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau
2015-01-23 14:02 GMT+01:00 hwaastad <he...@waastad.org>:
> Hi,
> got a question regarding tomee/jcs/jcache
>
>
> @Produces
> @WebCache
> @ApplicationScoped
> public CacheManager createManager() {
> System.out.println("Producing cache.......");
> try {
> URI uri =
> this.getClass().getClassLoader().getResource("cache.ccf").toURI();
> CachingProvider cachingProvider = Caching.getCachingProvider();
> return cachingProvider.getCacheManager(uri,
> Thread.currentThread().getContextClassLoader(),
> cachingProvider.getDefaultProperties());
>
> } catch (URISyntaxException ex) {
> System.out.println("USING DEFAULT CACHE MANAGER.......");
> return Caching.getCachingProvider().getCacheManager();
> }
> }
>
>
> @Produces
> @WebCacheType(CacheType.WEB)
> @ApplicationScoped
> public Cache createCache(@WebCache CacheManager manager) {
> return manager.createCache(
> "person_cache",
> new MutableConfiguration()
> .setStoreByValue(false)
> .setStatisticsEnabled(true)
> .setManagementEnabled(true)
> .setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(new
> Duration(TimeUnit.SECONDS, 3600L))));
> }
>
> If I'm right, it will be evicted from cache if not accessed in an hour?
>
> in tomee 1.7.1 right now its only in cache for a few milliseconds...
>
> this is my cache.ccf:
>
> jcs.default=DC
> jcs.default.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
> jcs.default.cacheattributes.MaxObjects=200001
> jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
> jcs.default.cacheattributes.UseMemoryShrinker=true
> jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
> jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
> jcs.default.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
> jcs.default.elementattributes.IsEternal=false
> jcs.default.elementattributes.MaxLife=700
> jcs.default.elementattributes.IdleTime=1800
> jcs.default.elementattributes.IsSpool=true
> jcs.default.elementattributes.IsRemote=true
> jcs.default.elementattributes.IsLateral=true
>
> However, using
> return Caching.getCachingProvider().getCacheManager();
>
> in CM producer, it's working OK.
>
> Am I doing something wrong here?
>
>
>
> br hw
>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.n4.nabble.com/tomee-jcache-question-tp4673495.html
> Sent from the TomEE Users mailing list archive at Nabble.com.