Results 1 to 4 of 4

Thread: using cache annotations with many cacheManagers

Hybrid View

  1. #1

    Default using cache annotations with many cacheManagers

    We are integrating many modules into a single application. Each module defines its own spring config files and we are aggregating these config files into a single ApplicationContext.
    Some modules have defined a CacheManager linked to a eh-cache config file, and use annotation-driven for proxying beans that need caching.

    The problem we are facing in that although the cache-manager property is configurable, we must integrate many cache-managers, each one containing caches that are used by beans from different modules.

    As an example, consider module 1, which defines a bean with methods annotated with @Cacheable. Its spring config file contains <cache:annotation-driven cache-manager="module1CacheManager"/>, and the definitino of a cacheManager, named "module1CacheManager", linked to the eh-cache config file named "eh-cache-module1.xml". This config files defines a cache named "usersCache", together with other global properties.

    Another module (module 2) defines a bean that also uses cache with annotations. Thus it contains a spring config file with a cacheManager named "module2CacheManager" and <cache:annotation-driven cache-manager="module2CacheManager"/>. The CacheManager references a eh-cache config file with a cache named "countryCache".

    We need to integrate both modules into a single application with a single Spring application context. When I create an application context with xml files from both modules, 2 cache managers are defined, but the second <cache:annotation-driven/> tag is ignored (and the 2nd cache manager too) as the cache-namespace parser only registers 1 cache aop advisor.

    There should be a way to specify the cache-manager name to use on a class-level for classes that use @Cacheable annotations (with a default to "cacheManager"), and remove the cache-manager attribute from <cache:annotation-driven/>.
    --
    Gaëtan PITTELOUD

  2. #2

    Default

    We too are facing the same issue, any updates on this?

  3. #3

    Default

    as you can see ... nope.

    I have created a jira with a proposal to support either @Qualifier or add a qualifier attribute to @Cacheable in order to be able to specify the cache manager name, in the same way it's done with @Transactional, and its value attribute.
    https://jira.springsource.org/browse/SPR-8696
    You can vote for it !
    --
    Gaëtan PITTELOUD

  4. #4
    Join Date
    Jan 2012
    Posts
    16

    Default

    Do you have a workaround now? We're trying to achieve something similar, but instead of having spring dependencies in all modules, we'll have a separate cache module to serve to other client modules for their caching needs. We're thinking to have one spring configuration in cache module, where it pulls properties files from other modules to configure caching, things like cache namespace, caching mechanisms, caching expireis, etc. However, we're not sure if this is all possible?

Tags for this Thread

Posting Permissions

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