Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: Declarative Caching

  1. #11
    Join Date
    Jul 2006
    Posts
    138

    Default

    So after playing with Declarative Caching, the first thing that I notice is that the Flushing Model flushes the entire cache. I see in the EhCacheFacade.java file that there is a method for "onRemoveFromCache" which removes a single object from the cache, however, I don't see an interface for doing so. It seems all-or-nothing. I'm sure there's a way to get it to remove one object at a time and not just flush the entire cache, but I haven't come across it yet.

  2. #12

    Default Issue with annotated caching

    my application context is the following...

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:ehcache="http://www.springmodules.org/schema/ehcache"
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
                            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
                            http://www.springframework.org/schema/context 
                            http://www.springframework.org/schema/context/spring-context-2.5.xsd
                            http://www.springmodules.org/schema/ehcache
                            http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd">
    
    	<context:component-scan base-package="com" />
    	
    	<ehcache:config configLocation="classpath:/ehcache.xml" serializableFactory="XSTREAM" />
     	
        <ehcache:annotations>
           <ehcache:caching id="testDaoCacheModel" cacheName="test1Cache" />
           <ehcache:caching id="testNonDaoCacheModel" cacheName="test2Cache" />
           <ehcache:flushing id="flushNonDaoCacheModel" cacheNames="test1Cache" />
        </ehcache:annotations> 
    	
        <!-- View Resolvers -->
        <bean id="bundledViewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
            <property name="basename" value="views"/>
            <property name="order" value="0"/>
        </bean>
        
    </beans>
    and this works perfect for annotating my methods for caching and flushing when I load the context files at the same time.

    However, I am experiencing an issue when my context files are loaded at different times...

    example:
    If I use spring-security and I load my security context in the web.xml file with a context-param tag, the above code is loaded in the applicationContext-servlet.xml file by spring. If I have any methods that are annotated in my spring-security context file, caching doesn't work for the methods loaded through my spring-security context file. I was wondering if there is a switch or a configuration option I need to set so that all of my annotated methods will be cached no matter when they are loaded?

    The only solution I have found so far is to find all of classes that I need to use for caching, along with my caching configuration and make sure they are loaded the same time my security context file is loaded... But I would imagine that it would be easier for people using this library to not have to worry about when to load their classes?

  3. #13
    Join Date
    Oct 2006
    Posts
    3

    Default

    Hi

    Quote Originally Posted by joshr View Post
    example:
    If I use spring-security and I load my security context in the web.xml file with a context-param tag, the above code is loaded in the applicationContext-servlet.xml file by spring. If I have any methods that are annotated in my spring-security context file, caching doesn't work for the methods loaded through my spring-security context file. I was wondering if there is a switch or a configuration option I need to set so that all of my annotated methods will be cached no matter when they are loaded?

    The only solution I have found so far is to find all of classes that I need to use for caching, along with my caching configuration and make sure they are loaded the same time my security context file is loaded... But I would imagine that it would be easier for people using this library to not have to worry about when to load their classes?
    We're also affected by this problem in our project. Is there another solution for this or do we have to load all caching in the security context?

    Regards

    Johan Hammar

  4. #14

    Default

    I haven't found any so far, I am guessing this issue should be raised as a bug.
    Last edited by joshr; Jan 19th, 2009 at 07:17 PM.

  5. #15
    Join Date
    Jan 2009
    Location
    South Africa
    Posts
    14

    Default

    Quote Originally Posted by joshr View Post
    I haven't found any so far, I am guessing this issue should be raised as a bug. I'll see if I can come up with a simple test case today...
    Im having same problem like yours and this is my thread: please take a look and give me some advises

    http://forum.springframework.org/showthread.php?t=66148

    Thanks in advance

  6. #16
    Join Date
    Jul 2009
    Posts
    1

    Default

    Quote Originally Posted by johanhammar View Post
    Hi



    We're also affected by this problem in our project. Is there another solution for this or do we have to load all caching in the security context?

    Regards

    Johan Hammar
    I ran into this post and also experienced the same issue. I had a web.xml that uses <context-param> to load up different xmls for data, service, security...etc and I found that the cache configuration needs to be place AFTER the intended cache beans are configured.

    So, I put my cache config (cache-service.xml) as the last file to be loaded in contextConfigLocation and everything is working.

    PHP Code:
    <context-param>
        <
    param-name>contextConfigLocation</param-name>
        <
    param-value>
        /
    WEB-INF/service.xml,
        /
    WEB-INF/data.xml,
        /
    WEB-INF/security.xml,
        /
    WEB-INF/cache-service.xml
        
    </param-value>
    </
    context-param

  7. #17
    Join Date
    Aug 2008
    Posts
    6

    Default Flushing Single Object

    Quote Originally Posted by RShelley View Post
    So after playing with Declarative Caching, the first thing that I notice is that the Flushing Model flushes the entire cache. I see in the EhCacheFacade.java file that there is a method for "onRemoveFromCache" which removes a single object from the cache, however, I don't see an interface for doing so. It seems all-or-nothing. I'm sure there's a way to get it to remove one object at a time and not just flush the entire cache, but I haven't come across it yet.
    I second this. Any points on how to approach flushing single object from cache?

  8. #18

    Default

    I am one of the authors of a new project intended to provide Ehcache integration for Spring 3 projects via annotations:

    http://code.google.com/p/ehcache-spring-annotations/

    We are excited to announce the general availability of the first production release, 1.0.1.

    This release provides 2 method-level annotations in the spirit of Spring’s @Transactional:

    @Cacheable
    @TriggersRemove

    When appropriately configured in your Spring application, this project will create caching aspects at runtime around your @Cacheable annotated methods.

    Usage documentation can be found on the project wiki:

    http://code.google.com/p/ehcache-spr...cheAnnotations
    http://code.google.com/p/ehcache-spr...TriggersRemove

  9. #19
    Join Date
    May 2010
    Posts
    2

    Default

    Hi edalquist,

    I am using spring 3.0 AOP to implement OSCache. But I am getting Spring meta data attributes exception as meta data class is not there in spring3.0-core jar while it was there in 2.5. I included spring-core 2.5.6.jar and after that it is not throwing exception but caching is not happening. If EHCache configuration is working fine with spring 3.0 , i am ok to implement it. But I am not getting any good documentation which gives all steps. Could you please guide on it?

    Following is the configuration/code I am using.
    --------------------------------------------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oscache="http://www.springmodules.org/schema/oscache"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.0.xsd
    http://www.springmodules.org/schema/oscache http://www.springmodules.org/schema/cache/springmodules-oscache.xsd">



    <oscache:config configLocation="classpath:oscache.properties"/>

    <oscache:annotations providerId="cacheProvider">
    <oscache:caching id="testCaching" groups="pb_test" cronExpression="*/30 * * *" refreshPeriod="864000"/>
    <oscache:flushing id="testFlushing" groups="pb_test"/>
    </oscache:annotations>



    </beans>

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

    oscache.properties :-
    cache.capacity=5000

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

    Code:-

    @Cacheable(modelId = "testCaching")
    public HashMap<String,String> getAllGlobalVariables()
    {
    HashMap<String,String> hm = new HashMap<String,String>();
    hm.put("test1", "test1");
    hm.put("test2", "test2");
    hm.put("PUB_PASSWORD_EXPIRE", "30");
    return hm;
    }


    ---------------------------------------------------
    Cache Log :-

    16 May 2010 22:52:16,587 DEBUG [] AbstractCacheAdministrator - Constructed AbstractCacheAdministrator()
    16 May 2010 22:52:16,587 INFO [] GeneralCacheAdministrator - Constructed GeneralCacheAdministrator()
    16 May 2010 22:52:16,587 INFO [] GeneralCacheAdministrator - Creating new cache
    16 May 2010 22:52:23,438 DEBUG [] Config - OSCache: Config called
    16 May 2010 22:52:23,438 DEBUG [] AbstractCacheAdministrator - Constructed AbstractCacheAdministrator()
    16 May 2010 22:52:23,438 INFO [] GeneralCacheAdministrator - Constructed GeneralCacheAdministrator()
    16 May 2010 22:52:23,438 INFO [] GeneralCacheAdministrator - Creating new cache
    --------------------------------------------------

  10. #20
    Join Date
    May 2010
    Posts
    2

    Default

    I tried to implement new google project for ehcache.
    But I am getting the problems there too as below.

    Hitting URL http://ehcache-spring-annotations.go...ehcache-spring is not giving any xsd file which is giving an error

    org.springframework.beans.factory.parsing.BeanDefi nitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://ehcache-spring-annotations.go...hcache-spring]

    Also it is giving an error with 1.0.2 jar as below. it is trying to look for spring-ehcache.xsd while in the jar ehcache-spring.xsd available.

    [DEBUG,PluggableSchemaResolver] Couldn't find XML schema [http://ehcache-spring-annotations.go...ring-1.0.xsd]: class path resource [com/googlecode/ehcache/annotations/spring-ehcache-1.0.xsd]
    java.io.FileNotFoundException: class path resource [com/googlecode/ehcache/annotations/spring-ehcache-1.0.xsd] cannot be opened because it does not exist

Posting Permissions

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