Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
ehcache-spring-annotations Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ehcache-spring-annotations

    as the springmodules projects seems pretty dead, and its cache module doesn't work in spring 3.0, i'm having a look at either write my own aop stuff for caching, or use the ehcache-spring-annotations fork.

    does anyone have experience with using the fork in a production / live environment? i mean is it mature enough?

    thanks

  • #2
    cross linking to a similar question here

    Comment


    • #3
      Originally posted by aVoice View Post
      as the springmodules projects seems pretty dead, and its cache module doesn't work in spring 3.0, i'm having a look at either write my own aop stuff for caching, or use the ehcache-spring-annotations fork.

      does anyone have experience with using the fork in a production / live environment? i mean is it mature enough?

      thanks

      I'm looking to use this, but have no idea how to configure the timeouts for those cachegroups. I can't see any examples on their site.

      Comment


      • #4
        To answer my post - you need to define these in your ehcache.xml. check the ehcache.org for details.

        I have this setup for some of my DAOs and it seems to work.

        Comment


        • #5
          If you are trying to use Spring 3.0, there is a new project listed at the end of this thread that uses annotations for caching. I haven't had time to try it out yet, but it might be worth looking into.

          http://forum.springsource.org/showth...t=47953&page=2

          Comment


          • #6
            I should have said, I am using ehcache-spring-annotations now and seems to work. My previous posts were in relation to this new project.

            Comment


            • #7
              As one of the authors of ehcache-spring-annotations I'd like to assure you that it is very much production ready. Nick (the other author) and I wrote it out of a need in several high-traffic applications we work on and we haven't had any issues with it.

              While I haven't actually done performance benchmarks on this versus spring-modules-cache I would surmise that it is significantly faster due to improvements in key generation and a significant reduction in the code that is executed by the caching aspect.

              Comment


              • #8
                Is there a similar project that supports JBoss Cache or if not how difficult is it to adapt ehcache-spring-annotation to work with JBoss?

                Comment


                • #9
                  There isn't a similar project that I know of.

                  We implemented ehcache-spring-annotations for ehcache specifically so there is no abstract away from the Ehcache classes. It likely could be done but I'm not sure how much work it would be.

                  Comment


                  • #10
                    I am going to try and modify your framework to make it JBoss-compatible. Although, I have never modified and static-linked an opensource project before. What are the rules with regards to the licensing and copyright/left? am I allowed to change the packaging or inject my code to the project using the same package names?
                    The new project (if successful) will be used internally in a proprietary enterprise application. Although I will be more than happy to contribute it back to the mother project to be assessed and possibly added to the framework if deemed good enough and upon permission from my company.

                    Thanks.

                    Comment


                    • #11
                      The project is under the Apache 2 license. I think you simply need to retain the copyright header on files that are already there and add a bit to the NOTICE file stating that some of the code is also copy written by you.

                      We would be happy to consider your changes for inclusion in the project. As you get working on it please feel free to join the project mailing list and ask questions there about the best ways to get this implemented such that we could consider it for inclusion.

                      Comment


                      • #12
                        Project Roadmap

                        What is the project roadmap for the ehcache-annotations projects. Looks pretty new and that's what worrying me.

                        Comment


                        • #13
                          At this point the two big roadmap items are plugable cache support (we might rename the project for that one) and AspectJ support. The code base is in heavy use a the University of Wisconsin - Madison's central IT department (where the two of us that wrote it work) and a lot of the open source projects we work on are also using it.

                          Are there specific features or items you'd like to see on a roadmap?

                          Comment


                          • #14
                            Roadmap

                            Well an active roadmap , gives confidence to use the codebase.

                            From the documentation, I can see that the caching strategy is based on a key being generated.

                            However, what I am looking for is something like this.

                            Assume that the key generated is 29-08-2010 : Then the underlying service needs to be invoked

                            If the key generated is 28-08-2010(less than today' date) : Then serve the request with the data from the cache.

                            Is something like this possible ?

                            Thanks,
                            Franklin

                            Comment


                            • #15
                              I put together a brief road map page: http://code.google.com/p/ehcache-spr...s/wiki/RoadMap


                              What you want to do can be done with a custom CacheKeyGenerator [1] implementation. While the framework will provide your key generator with a reference to the MethodInvocation there is no reason you have to use it. Assuming your example is date based a simple key generator like:

                              Code:
                              package com.example;
                              
                              import java.io.Serializable;
                              import java.text.SimpleDateFormat;
                              import java.util.Date;
                              
                              import org.aopalliance.intercept.MethodInvocation;
                              
                              import com.googlecode.ehcache.annotations.key.CacheKeyGenerator;
                              
                              public class DateCacheKeyGenerator implements CacheKeyGenerator<Serializable> {
                                  private final SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); 
                              
                                  @Override
                                  public Serializable generateKey(MethodInvocation methodInvocation) {
                                      return this.generateKey((Object)methodInvocation);
                                  }
                              
                                  @Override
                                  public Serializable generateKey(Object... data) {
                                      
                                      final Date now = new Date();
                                      
                                      synchronized (this.dateFormat) {
                                          return dateFormat.format(now);
                                      }
                                  }
                              }
                              Then reference this generator in your annotation:
                              Code:
                              @Cacheable(cacheName="exampleCache", 
                                  keyGenerator = @KeyGenerator (name = "com.example.DateCacheKeyGenerator")
                                  )
                              public ExampleData getData(String arg1, Object arg2);
                              Now while that should be a functional key generator (I didn't actually test it) it could be improved on a by doing things like using a Timer to generate the date string once per minute and storing it in a volatile field instead of generating the date string every time the cached method is requested.

                              [1] http://ehcache-spring-annotations.go...Generator.html

                              Comment

                              Working...
                              X