【发布时间】:2011-10-29 22:09:38
【问题描述】:
除了Spring 3.1 和ehcache-spring-annotations,除了EhCache 和Spring,我们还有其他选择吗?
【问题讨论】:
标签: java caching annotations ehcache declarative
除了Spring 3.1 和ehcache-spring-annotations,除了EhCache 和Spring,我们还有其他选择吗?
【问题讨论】:
标签: java caching annotations ehcache declarative
您是否查看过基于 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" />
【讨论】: