code-4-fun / ehcache-spring-annotations

Automatically exported from code.google.com/p/ehcache-spring-annotations
0 stars 0 forks source link

Enhancement: Split the @Cacheable annotation into multiple annotations #89

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm working on adding per-request caching in my application. It looks like I 
can do this using the resolverFactory argument for @Cacheable.

However, this appears inflexible as I will have to make the same change to all 
@Cacheable entries that I want on a per-request basis:

@Cacheable(cacheName = "valuationCalendar", 
resolverFactory=@ResolverFactory(name = 
"ch.hedgesphere.core.ehcache.RequestScopeCacheResolverFactory"))

...

@Cacheable(cacheName = "positions", resolverFactory=@ResolverFactory(name = 
"ch.hedgesphere.core.ehcache.RequestScopeCacheResolverFactory"))

If the @ResolverFactory annotation was split out:

@ResolverFactory("ch.hedgesphere.core.ehcache.RequestScopeCacheResolverFactory")
@Cacheable(cacheName = "valuationCalendar")

I could then wrap the @ResolverFactory in another annotation:

@Retention(RUNTIME)
@Target( { METHOD })
@ResolverFactory("ch.hedgesphere.core.ehcache.RequestScopeCacheResolverFactory")
public @interface RequestScopedCache {}

Which leads to the cleaner declaration of:

@RequestScopedCache
@Cacheable(cacheName = "valuationCalendar")

Original issue reported on code.google.com by steven.d...@gmail.com on 1 Nov 2011 at 2:33