文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > ehcache实例
侵权投诉

ehcache实例

AOP,需要2个拦截器:

1. 一个是方法执行前查找缓存的拦截器;(query方法执行前先查找是否有缓存,如果有,

走缓存,如果没有,执行方法,并且把结果缓存)

2. 另一个是方法执行后销毁缓存的拦截器;(update,insert,delete等方法执行后需要销毁缓

存)

方法执行前的拦截器MethodCacheInterceptor.java:

Java代码

package ehcache;

Import java.io.Serializable;

import org.aopalliance.intercept.MethodInterceptor;

import org.aopalliance.intercept.MethodInvocation;

import org.apache.commons.logging.LogFactory;

import org.apache.commons.logging.Log;

import org.springframework.beans.factory.InitializingBean;

import org.springframework.util.Assert;

import net.sf.ehcache.Cache;

import net.sf.ehcache.Element;

public class MethodCacheInterceptor implements MethodInterceptor, InitializingBean { private static final Log logger = LogFactory.getLog(MethodCacheInterceptor.class);

private Cache cache;

public void setCache(Cache cache) {

this.cache = cache;

}

public void afterPropertiesSet() throws Exception {

Assert.notNull(cache, "A cache is required. Use setCache(Cache) to provide one."); }

public Object invoke(MethodInvocation invocation) throws Throwable {

String targetName = invocation.getThis().getClass().getName();

String methodName = invocation.getMethod().getName();

Object[] arguments = invocation.getArguments();

Object result;

第1页

你可能喜欢

热门文档

相关文档

  • Ehcache中文指南和实例教程

    Ehcache中文指南和实例教程_互联网_IT/计算机_专业资料。Ehcache 内存框架介绍 1. 背景及基础介绍 目的:使用缓存技术缓解数据库压力,提高访问速度,牺牲内存空间换取...

  • Spring3 1整合EhCache注解实例

    Spring3 1整合EhCache注解实例_互联网_IT/计算机_专业资料 暂无评价0人阅读0次下载举报文档 Spring3 1整合EhCache注解实例_互联网_IT/计算机_专业资料。 ...

  • Ehcache学习应用

    EhCache Server 同时也提供强大的安全机制、监控功能。在数据存储方面,最大的 Ehcache 单实例在内存中可以缓存 20GB。最大的磁盘可以缓存 100GB。通过将节点整合在...

  • maven + spring + hibernate + mysql + ehcache实例(注...

    maven + spring + hibernate + mysql + ehcache实例(注解方式实现)_计算机软件及应用_IT/计算机_专业资料。 折腾了2天。 看spring in action看到一半,觉得搭...

  • ehcache配置

    具体的实例如下: <cacheManagerPeerProviderFactoryclass="net.sf.ehcache.distribution. RMICacheManagerPeerProviderFactory" properties="peerDiscovery=manual, rmiUrls=//...

  • ehcache使用文档

    支持多缓存管理器实例,以及一个实例的多个缓存区域 提供 Hibernate 的缓存实现 2 安装和使用 2.1 下载 Ehcache 的官方网站http://ehcache.org/downloads/catalog...

  • ehcache学习文档

    下面是 ehcache.xml 具体实例以及配置指南 <ehcache xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance CacheManager 配置 DmulticastGroupPort=4446,这样可以...

  • EHCache技术文档详解

    EHCache技术文档详解_IT/计算机_专业资料。记录使用EHCache实现页面级的缓存以及...支持多缓存管理器实例,以及一个实例的多个缓存区域 9. 提供 Hibernate 的缓存...

  • Ehcache缓存配置 - 企业应用 - Java - ITeye论坛

    下面是ehcache.xml具体实例以及配置指南 <ehcache xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance · CacheManager配置 DmulticastGroupPort=4446,这样可以...

  • ehcache技术详解

    (6) 支持多缓存管理器实例,以及一个实例的多个缓存区域 2 部署 2.1 引入 官网地址:http://www.ehcache.org/ 下载发布包 ehcache-2.8.1-distribution.tar....

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email