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

    主站蜘蛛池模板: 久久影院亚洲一区| 日韩在线一区二区三区免费视频 | 希望影院高清免费观看视频| 欧洲亚洲综合一区二区三区| 亚洲精品国产福利在线观看| 亚洲乱码精品久久久久..| 四虎1515hm免费国产| 最新中文字幕电影免费观看| 99精品热线在线观看免费视频| 污视频网站免费在线观看| 中文字幕亚洲综合久久综合| 亚洲黄网在线观看| 亚洲国产精品无码久久一线| 亚洲精品久久久www | 久久久青草青青亚洲国产免观| 国产无遮挡又黄又爽免费视频| 免费人成网站在线观看10分钟| 三年片在线观看免费观看大全动漫 | 久久亚洲高清观看| 亚洲色成人网站WWW永久| 亚洲精品WWW久久久久久| 免费女人18毛片a级毛片视频| 日韩a级毛片免费观看| 午夜电影免费观看| 手机在线毛片免费播放| 免费精品国偷自产在线在线| 在线看片v免费观看视频777 | 亚洲久本草在线中文字幕| 中文国产成人精品久久亚洲精品AⅤ无码精品| 国产精品四虎在线观看免费| 精品免费国产一区二区| 在线观看免费国产视频| 国产免费观看黄AV片| 可以免费观看的一级毛片| 亚洲AV伊人久久青青草原| 免费一级毛片在线播放视频| 一本天堂ⅴ无码亚洲道久久| 国产亚洲精品成人AA片| 亚洲av成本人无码网站| 色屁屁在线观看视频免费| 国产黄片不卡免费|