Results 1 to 2 of 2

Thread: Cacheable doing nothing

  1. #1
    Join Date
    Mar 2012
    Posts
    2

    Default Cacheable doing nothing

    Hello,

    I tried to add some ehcache to my webapp.
    I have read severals tutorials and documentation. All seems in place, with no error everything running fine except that everytime I hit F5 I see that the cached method is executed like if there were no cache:

    application context :
    Code:
    <cache:annotation-driven />
    	<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cache-manager-ref="ehcache"/>
    	<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:config-location="classpath:ehcache.xml"/>
    ehcache :

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
        <!--
        <defaultCache eternal="true" maxElementsInMemory="100" overflowToDisk="false" />
        <cache name="myCache" maxElementsInMemory="40" eternal="true" overflowToDisk="false" />
        -->
        <diskStore path="java.io.tmpdir"/>
        <cache name="myCache"
           maxElementsInMemory="100"
                eternal="false"
                timeToIdleSeconds="1200"
                timeToLiveSeconds="1200"
                overflowToDisk="true"
                maxElementsOnDisk="10000000"
                diskPersistent="false"
                diskExpiryThreadIntervalSeconds="1200"
                memoryStoreEvictionPolicy="LRU"/>
    </ehcache>

    My controller looks like this

    Code:
    @Controller
    @RequestMapping("/mypage")
    public class MyController {
    
        @Cacheable(value ="myCache", key="locale")
        public MyObject getMyObject(Locale locale){
    		Logger l = Logger.getLogger(this.getClass());
    		l.error("calling getMyObject");
            ...
        }
    
        @RequestMapping
        public String index(ModelMap model, Locale locale) {
            ...
            a = getMyObject(locale);
            ...
        }
    }

    everytime I hit f5 I can see in the log :
    "calling getMyObject"
    When I guess, I should see it only the first time ? or maybe I am wrong somewhere ?

    Thanks for help !
    Last edited by jpprade; Mar 15th, 2012 at 03:14 AM.

  2. #2
    Join Date
    Mar 2012
    Posts
    2

    Default

    My issue looks like this thread :

    http://stackoverflow.com/questions/8...ng-aspectj-ltw

    trying the mode="aspectj"

    but with when I add a @Cacheable method I get this exception :

    java.lang.ClassNotFoundException: mypackage.MyController$AjcClosure1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •