<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    paulwong

    Spring基于注解的緩存配置--web應用實例

    基于方法級別的緩存:通常如果一個帶有參數的方法執行后會返回一個Object,那可以認為如果參數相同,則返回的結果一樣,這樣就可以為這個方法建立一個緩存Map,參數就是KEY,返回的結果就是VALUE,調用此方法前可以先判斷參數是否和之前的一樣,如果是則從Map中取出結果返回調用者,而無需再進入此方法內執行得到,從而節省了此方法執行時的時間。

    http://hanqunfeng.iteye.com/blog/605123

    經驗證,如果要支持分布式的緩存,用spring-modules-cache不好使,必須轉用com.googlecode.ehcache-spring-annotations

    全套MAVEN的POM:
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation
    ="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        
    <modelVersion>4.0.0</modelVersion>
        
    <groupId>EhCache-Cluster-Tester</groupId>
        
    <artifactId>EhCache-Cluster-Tester</artifactId>
        
    <version>0.0.1-SNAPSHOT</version>
        
    <packaging>war</packaging>
        
    <dependencies>
            
    <dependency>
                
    <groupId>net.sf.ehcache</groupId>
                
    <artifactId>ehcache-jgroupsreplication</artifactId>
                
    <version>1.4</version>
            
    </dependency>
            
    <!-- Spring framework -->
            
    <dependency>
                
    <groupId>org.springframework</groupId>
                
    <artifactId>spring</artifactId>
                
    <version>${spring.version}</version>
            
    </dependency>

            
    <!-- Spring MVC framework -->
            
    <dependency>
                
    <groupId>org.springframework</groupId>
                
    <artifactId>spring-webmvc</artifactId>
                
    <version>${spring.version}</version>
            
    </dependency>
            
    <dependency>
                
    <groupId>javax.servlet</groupId>
                
    <artifactId>servlet-api</artifactId>
                
    <version>2.4</version>
                
    <scope>provided</scope>
            
    </dependency>
            
    <dependency>
                
    <groupId>org.slf4j</groupId>
                
    <artifactId>slf4j-jdk14</artifactId>
                
    <version>1.5.6</version>
                
    <type>jar</type>
                
    <scope>compile</scope>
            
    </dependency>
            
    <dependency>
                
    <groupId>log4j</groupId>
                
    <artifactId>log4j</artifactId>
                
    <version>1.2.13</version>
                
    <type>jar</type>
                
    <scope>compile</scope>
            
    </dependency>
            
    <dependency>
                
    <groupId>cglib</groupId>
                
    <artifactId>cglib-nodep</artifactId>
                
    <version>2.2.2</version>
                
    <type>jar</type>
                
    <scope>compile</scope>
            
    </dependency>
            
    <!-- 
            <dependency>
                <groupId>org.springmodules</groupId>
                <artifactId>spring-modules-cache</artifactId>
                <version>0.9</version>
                <type>jar</type>
                <scope>compile</scope>
            </dependency>
            
    -->
            
    <dependency>
                
    <groupId>com.googlecode.ehcache-spring-annotations</groupId>
                
    <artifactId>ehcache-spring-annotations</artifactId>
                
    <version>1.2.0</version>
                
    <type>jar</type>
                
    <scope>compile</scope>
                
    <exclusions>
                    
    <exclusion>
                        
    <artifactId>spring-aop</artifactId>
                        
    <groupId>org.springframework</groupId>
                    
    </exclusion>
                    
    <exclusion>
                        
    <artifactId>spring-expression</artifactId>
                        
    <groupId>org.springframework</groupId>
                    
    </exclusion>
                
    </exclusions>
            
    </dependency>
        
    </dependencies>
        
    <build>
            
    <finalName>cluster-test</finalName>
            
    <plugins>
                
    <plugin>
                    
    <groupId>org.apache.maven.plugins</groupId>
                    
    <artifactId>maven-compiler-plugin</artifactId>
                    
    <configuration>
                        
    <source>1.6</source>
                        
    <target>1.6</target>
                        
    <encoding>UTF-8</encoding>
                    
    </configuration>
                
    </plugin>
                
    <plugin>
                    
    <groupId>org.mortbay.jetty</groupId>
                    
    <artifactId>jetty-maven-plugin</artifactId>
                    
    <version>8.0.4.v20111024</version>
                    
    <!-- 
                    <artifactId>maven-jetty-plugin</artifactId>
                    <version>6.1.26</version>
                    
    -->
                    
    <configuration>
                        
    <contextPath>/cluster-test</contextPath>
                        
    <scanIntervalSeconds>3</scanIntervalSeconds>
                        
    <scanTargetPatterns>
                            
    <scanTargetPattern>
                                
    <directory>src/main/webapp/WEB-INF</directory>
                                
    <excludes>
                                    
    <exclude>**/*.jsp</exclude>
                                
    </excludes>
                                
    <includes>
                                    
    <include>**/*.properties</include>
                                    
    <include>**/*.xml</include>
                                
    </includes>
                            
    </scanTargetPattern>
                        
    </scanTargetPatterns>
                    
    </configuration>
                
    </plugin>
            
    </plugins>
        
    </build>
        
    <properties>
            
    <spring.version>2.5.2</spring.version>
        
    </properties>
    </project>

    posted on 2012-02-16 17:04 paulwong 閱讀(2847) 評論(0)  編輯  收藏 所屬分類: 緩存

    主站蜘蛛池模板: WWW免费视频在线观看播放 | 欧洲乱码伦视频免费国产 | 亚洲AV午夜成人片| h片在线免费观看| 亚洲一区二区三区国产精华液| 免费人成视频x8x8入口| 国产三级在线免费| 中国亚洲呦女专区| 最新国产精品亚洲| 亚洲精品国产精品国自产观看| 99视频在线精品免费| 亚洲日产乱码一二三区别 | 亚洲激情中文字幕| 国产美女无遮挡免费视频网站| 三年片免费观看大全国语| 亚洲综合精品第一页| 丁香五月亚洲综合深深爱| 色妞WWW精品免费视频 | 亚洲国产精品日韩| 无码区日韩特区永久免费系列 | 国产精品视_精品国产免费| 中文字幕免费不卡二区| 亚洲精品av无码喷奶水糖心| 久久精品亚洲综合一品| 亚洲精品综合久久| 免费看国产成年无码AV片| 免费在线看黄网站| 疯狂做受xxxx高潮视频免费| 亚洲最大黄色网站| 亚洲AV综合色一区二区三区| 又粗又硬又黄又爽的免费视频| 日韩不卡免费视频| 免费观看男人吊女人视频| 香蕉视频免费在线播放| 久久乐国产综合亚洲精品| 亚洲好看的理论片电影| 亚洲日韩精品一区二区三区 | 成年男女男精品免费视频网站| 免费人成网站在线观看不卡| 成年免费大片黄在线观看com| 亚洲国产精品无码中文lv|