更改子方法的缓存管理器

时间:2018-11-15 09:52:53

标签: spring-cache

@CacheConfig(cacheManager = ACacheManager, cacheNames = ACache)
class A {

    @Cacheable(key = "#user.userName", cacheManager="ACacheManager", cacheNames= {"ACache"})
    methodA (User user) {
    }
}


@CacheConfig(cacheManager = BCacheManager, cacheNames = BCache)
class B extends A {

    @Cacheable(key = "#user.userName", cacheManager="BCacheManager", cacheNames= {"BCache"})
    @Override
    methodA (User user) {
    }
}

A a = new A();   a.methodA();结果应保存在ACacheManager的缓存ACache中

A b = new B();
  b.methodA();结果应保存在BCacheManager的缓存BCache中

0 个答案:

没有答案