Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: ehcache-spring-annotations

  1. #11

    Default

    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.

  2. #12

    Default Project Roadmap

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

  3. #13

    Default

    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?

  4. #14

    Default 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

  5. #15

    Default

    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

  6. #16

    Default Give it a try

    Excellent. I shall give it a try and get back to you with any troubles I may face.

    Regards,
    Franklin

Posting Permissions

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