【问题标题】:Declarative (Annotation-based) Caching Solution for JavaJava 的声明式(基于注释的)缓存解决方案
【发布时间】:2011-10-29 22:09:38
【问题描述】:

除了Spring 3.1ehcache-spring-annotations,除了EhCache 和Spring,我们还有其他选择吗?

【问题讨论】:

    标签: java caching annotations ehcache declarative


    【解决方案1】:

    您是否查看过基于 Spring-AOP 的解决方案?您可以使用 org.springframework.aop.support.RegexpMethodPointcutAdvisor 在 Spring applicationContext 中创建一个自动代理对象,然后创建一个实现 AfterReturningAdvice、ThrowsAdvice 的对象>MethodBeforeAdvice

    使用该对象来监视函数调用和退出并缓存您想要的信息。

    <bean name="cacheHandler" class="org.yourname.CachingInterceptor" />
    <bean id="cacheAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
      <property name="advice" ref="cacheHandler" />
      <property name="pattern" value="org.yourname.regex.of.stuff.you.want.cached.*" />
    </bean>
    <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-01
      • 1970-01-01
      • 2014-05-15
      • 1970-01-01
      • 2011-12-10
      • 2014-09-11
      相关资源
      最近更新 更多