[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Values not getting cached  XML
Forum Index -> Ehcache
Author Message
satya087

journeyman

Joined: 10/14/2010 05:58:35
Messages: 16
Offline

Hi,
i am using spring annotation based caching, the cache is created but on subsequent request to same method the values are not cached. can you suggest what can be the problem
---------------------------------------------
//StatesDAO class

@Cacheable(cacheName="stateCache")
public List findAllStates() throws DAOException {

//some code that returns a list of states.
return list;
}
------------------------------------------
//ehcache.xml

<cache name="stateCache"
maxElementsInMemory="1000"
eternal="true"
overflowToDisk="false"
memoryStoreEvictionPolicy="LFU" >
</cache>

---------------------------------------------

//ApplicationContext

<ehcache:annotation-driven cache-manager="ehCacheManager" />

<bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" >
<property name="configLocation">
<value>/WEB-INF/ehcache.xml</value>
</property>
</bean>

<bean id="statesDAO" class="StatesDAO" parent="baseDAOBean"/>
-----------------------------------------------------
//pom.xml

<dependency>
<groupId>com.googlecode.ehcache-spring-annotations</groupId>
<artifactId>ehcache-spring-annotations</artifactId>
<version>1.1.2</version>
</dependency>

<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.1.0</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.6.1</version>
</dependency>

<dependency>
<groupId>org.springmodules</groupId>
<artifactId>spring-modules-cache</artifactId>
<version>0.9</version>
</dependency>
-----------------------------------------------------

Here the cache is getting created but the values that the method returns ,doesnt get cached. can you please suggest what else to do
BluJay

neo

Joined: 10/23/2010 15:04:53
Messages: 1
Offline

I'm getting the same issue. I have my Spring Annotations and EhCache set up but the chaching doesn't seem to be in effect (it's no faster... even with a forced delay of three seconds!!).

Anyone have any ideas?

Cheers
Jay
alexsnaps

consul

Joined: 06/19/2009 09:06:00
Messages: 484
Offline

I've spent sometime looking into this.
It seems, depending on how you get access to your bean with cached methods, you might or not get results cached.
I've created a small test app that failed as well. It first only had the SimpleAppTest. I then looked into how the ehcache annotation project had its tests written and created the AutowiredAppTest, which passes for some reason.
I've submitted that to the ehcache-annotation guys for a more in depth explanation here. In the meantime, I hope that example helps...
 Filename cacheMethods.tar.bz2 [Disk] Download
 Description Sample app
 Filesize 11 Kbytes
 Downloaded:  203 time(s)


Alex Snaps (Terracotta engineer)
edalquis

journeyman

Joined: 02/10/2010 10:44:27
Messages: 11
Offline

How are you loading the spring ApplicationContext?
How are you calling findAllStates()?
rajoshi

seraphim

Joined: 07/04/2011 04:36:10
Messages: 1491
Offline

Issue seems to be resolved.Please let us know if more information is required.

Rakesh Joshi
Senior Consultant
Terracotta.
 
Forum Index -> Ehcache
Go to:   
Powered by JForum 2.1.7 © JForum Team