Announcement Announcement Module
Collapse
No announcement yet.
Unobstrusive Spring Caching Abstraction Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unobstrusive Spring Caching Abstraction

    I like the new Cache abstraction that is possible using Annotations. I am wondering if there's been thought put toward enabling Cache abstraction for classes that you don't have control of (third-party libs).

    Maybe something like:

    Code:
    @Bean
    @CacheableBean(cacheInstructor = AbstractCachingThirdPartyApi.class)
    public ThirdPartyApi thirdPartyApi() {
      return new ThirdPartyApiImpl();
    }
    ...

    Code:
    // The same approach could be taken for classes instead of interface, if necessary
    public abstract class AbstractCachingThirdPartyApi implements ThirdPartyApi {
      // Any methods that should be cached can be annotated
      @Cacheable("responseObjectCache")
      public abstract ResponseObject fetchObject(int id);
    }
    The reason why I say this is because the cleanest alternative I've come up with is using classes that refer to delegates.
Working...
X