<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 閱讀(2850) 評論(0)  編輯  收藏 所屬分類: 緩存

    主站蜘蛛池模板: 最好免费观看韩国+日本| 亚洲视频在线观看免费| 13小箩利洗澡无码视频网站免费| 2021在线永久免费视频| 免费观看亚洲人成网站| 亚洲一区综合在线播放| 日韩国产欧美亚洲v片| 成人自慰女黄网站免费大全| av无码免费一区二区三区| 亚洲精品黄色视频在线观看免费资源| 久久久久亚洲AV无码观看 | 亚洲va久久久噜噜噜久久| 中文字幕亚洲男人的天堂网络| 一级做a爰片久久免费| 美女网站免费福利视频| 亚洲伊人色欲综合网| 亚洲熟妇无码AV不卡在线播放| 免费无码黄网站在线看| 日韩一区二区在线免费观看| 亚洲免费在线视频| 国产精品日本亚洲777| 久久精品国产免费观看| 中文字幕在亚洲第一在线| 亚洲私人无码综合久久网| 午夜精品免费在线观看 | 亚洲视屏在线观看| 成人午夜免费视频| 国产人在线成免费视频| 国产成人精品日本亚洲网站| 亚洲AV无码一区二区三区牲色 | 国产成人精品日本亚洲语音| 5555在线播放免费播放| 亚洲一区二区三区免费| 亚洲色丰满少妇高潮18p| 亚洲最大免费视频网| 亚洲日韩中文字幕在线播放| 色偷偷亚洲男人天堂| 国产精品久久久久免费a∨| 亚洲成AV人片在| 一级一级毛片免费播放| 日韩免费视频播放|