| Author |
Message |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 05/02/2011 23:14:56
|
amittare
neo
Joined: 05/02/2011 23:03:48
Messages: 4
Offline
|
I am using ehcache 1.1 jar in my application. I am having singleton instance of cache object which is used to put and get elements. I am not sure how to distinguish it as standalone or distributed, so if you can just ask me questions on this so that it gets clarified to you in order to understand and solve my problem.
My problem is the get(key) works most of the times, but at times it returns null from the cache for the key actually existing in the cache.
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 05/03/2011 06:59:04
|
klalithr
consul
Joined: 01/23/2011 10:58:07
Messages: 466
Offline
|
I recommend that you start with the ehcache documentation and try the samples found here...
http://ehcache.org/documentation/samples.html
|
Karthik Lalithraj (Terracotta) |
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 05/03/2011 07:26:17
|
ari
seraphim
Joined: 05/24/2006 14:23:21
Messages: 1665
Location: San Francisco, CA
Offline
|
How are you even finding ehcache 1.1? It really isn't available to download anywhere, is it?
--Ari
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 05/03/2011 23:26:08
|
amittare
neo
Joined: 05/02/2011 23:03:48
Messages: 4
Offline
|
Actually my application is 6 years old, and that is the ehcache version my application is using right from start I guess. I am looking after enhancements of the application.
Also the ehcache is used as standalone.
Please let me know any remedy for my problem.
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 05/04/2011 04:17:24
|
klalithr
consul
Joined: 01/23/2011 10:58:07
Messages: 466
Offline
|
Firstly - I would recommend that you move to the most recent version of Ehcache. This could very well solve your issue. Please try this as step 1.
Secondly, Get could also return null if the element has expired due to TTI and TTL settings in the cache. I need more information about your use case to accurately help you out. Please share your ehcache.xml, the code that you use to get the element (3-4 lines around it would suffice - are you using iskeyincache) , and how you determine that element is present in the cache?
|
Karthik Lalithraj (Terracotta) |
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 05/04/2011 23:47:36
|
amittare
neo
Joined: 05/02/2011 23:03:48
Messages: 4
Offline
|
1) My ehcache.xml :
<ehcache>
<diskStore path="java.io.tmpdir" />
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
overflowToDisk="false"
/>
<cache name="bamEntryCache"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="3600"
overflowToDisk="false"
/>
<cache name="globalUidCache"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="86400"
timeToLiveSeconds="86400"
overflowToDisk="false"
/>
<cache name="serverTabCache"
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="86400"
timeToLiveSeconds="86400"
overflowToDisk="false"
/>
</ehcache>
2) The code is not using iskeyincache().
3) Code used to get the element :
try {
Element element = cache.get((Serializable) key);
if (element != null) {
result = element.getValue();
} else {
result = null;
}
} catch (IllegalStateException e) {
log.warn(e, e);
} catch (CacheException e) {
log.warn(e, e);
}
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 05/05/2011 05:41:23
|
klalithr
consul
Joined: 01/23/2011 10:58:07
Messages: 466
Offline
|
Did you move to the most recent version of Ehcache? 1.1 is very old.
Based on your TTI/TTL settings, you have those set to 1 hour for bamEntryCache and 1 day for globalUIdCache. Also MaxElementsInMemory is set to 10000. Anything outside these boundaries would result in a cache miss - this is expected behavior. For more information on how these work I would suggest looking at the documentation in ehcache website
http://ehcache.org/documentation/configuration.html
|
Karthik Lalithraj (Terracotta) |
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 05/09/2011 02:27:09
|
amittare
neo
Joined: 05/02/2011 23:03:48
Messages: 4
Offline
|
No, I haven't moved to recent version yet.
When we say MaxElementsInMemory, is it the number of elements we put in cache by invoking cache.put(new Element(key,value)) ?
Will you please clarify on this for me ?
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 07/22/2011 07:12:25
|
rajoshi
seraphim
Joined: 07/04/2011 04:36:10
Messages: 1465
Offline
|
Issue seems to be resolved.Please let us know if more information is required.
|
Rakesh Joshi
Terracotta. |
|
|
 |
|
|