<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)  編輯  收藏 所屬分類: 緩存

    主站蜘蛛池模板: 亚洲AV福利天堂一区二区三| 亚洲一区二区三区高清在线观看| 最好看最新的中文字幕免费| 亚洲一级毛片中文字幕| 国产午夜无码视频免费网站| a级精品九九九大片免费看| 亚洲免费福利在线视频| 国产乱辈通伦影片在线播放亚洲| 91成人免费观看| 四虎精品成人免费视频| 麻豆亚洲av熟女国产一区二| 四虎影视在线永久免费看黄| 久久ww精品w免费人成| 黄色一级视频免费观看| 亚洲视频欧洲视频| 2022中文字字幕久亚洲| 无码少妇一区二区浪潮免费| 三级网站免费观看| 亚洲国产精品久久久久秋霞小| 亚洲AV中文无码字幕色三| 国产美女精品视频免费观看| 女人体1963午夜免费视频| 国产成人人综合亚洲欧美丁香花| 亚洲国产精品lv| 国产精品亚洲玖玖玖在线观看| 成人无码区免费视频观看| 午夜网站在线观看免费完整高清观看| 亚洲av永久无码精品秋霞电影秋| 亚洲AV无码国产丝袜在线观看| 免费永久在线观看黄网站| 91九色精品国产免费| 永久免费AV无码网站国产 | 亚洲欧洲高清有无| 亚洲美女高清一区二区三区| 最新中文字幕电影免费观看| 四虎影视在线影院在线观看免费视频| 一级女性全黄久久生活片免费| 亚洲午夜精品一区二区麻豆 | 无套内谢孕妇毛片免费看看| 亚洲视频在线观看2018| 亚洲视频国产视频|