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

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

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

    少年阿賓

    那些青春的歲月

      BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
      500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks

    學(xué)習(xí)了memcache,這是個(gè)好東西,分享一下自己的小實(shí)例,也方便以后查找使用

    一、前期準(zhǔn)備

    1)  下載memcached服務(wù)端memcached-1.2.6-win32-bin.zip,地址:http://code.jellycan.com/memcached/

    2)  下載java版客戶端 java_memcached-release_2.6.1.zip
    3)  解壓縮memcached-1.2.6-win32-bin.zip到指定目錄,例如:D:\memcached-1.2.6-win32 ,在終端(即cmd命令行界面)
     
    D:\memcached-1.2.6-win32\memcached.exe -d install
    D:\memcached\memcached.exe -d start
     
    這樣memcache就會(huì)作為windows系統(tǒng)服務(wù)在每次開機(jī)時(shí)啟動(dòng)memcache服務(wù)。
     
    常用命令
     
    -p 監(jiān)聽的端口 
    -l 連接的IP地址, 默認(rèn)是本機(jī) 
    -d start 啟動(dòng)memcached服務(wù) 
    -d restart 重起memcached服務(wù) 
    -d stop|shutdown 關(guān)閉正在運(yùn)行的memcached服務(wù) 
    -d install 安裝memcached服務(wù) 
    -d uninstall 卸載memcached服務(wù) 
    -u 以的身份運(yùn)行 (僅在以root運(yùn)行的時(shí)候有效) 
    -m 最大內(nèi)存使用,單位MB。默認(rèn)64MB 
    -M 內(nèi)存耗盡時(shí)返回錯(cuò)誤,而不是刪除項(xiàng) 
    -c 最大同時(shí)連接數(shù),默認(rèn)是1024 
    -f 塊大小增長因子,默認(rèn)是1.25 
    -n 最小分配空間,key+value+flags默認(rèn)是48 
    -h 顯示幫助 



    spring-memcache.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi
    ="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:cache
    ="http://www.springframework.org/schema/cache"
        xmlns:context
    ="http://www.springframework.org/schema/context"
        xmlns:mvc
    ="http://www.springframework.org/schema/mvc" xmlns:oxm="http://www.springframework.org/schema/oxm"
        xmlns:p
    ="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
        xsi:schemaLocation
    ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd  
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd  
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd  
           http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
           http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">

        
    <bean id="memcachedPool" class="com.danga.MemCached.SockIOPool"
            factory
    -method="getInstance" init-method="initialize" destroy-method="shutDown">
            
    <constructor-arg>
                
    <value>neeaMemcachedPool</value>
            
    </constructor-arg>
            
    <property name="servers">
                
    <list>
                    
    <value>127.0.0.1:11211</value>
                
    </list>
            
    </property>
            
    <property name="initConn">
                
    <value>20</value>
            
    </property>
            
    <property name="minConn">
                
    <value>10</value>
            
    </property>
            
    <property name="maxConn">
                
    <value>50</value>
            
    </property>
            
    <property name="maintSleep">
                
    <value>3000</value>
            
    </property>
            
    <property name="nagle">
                
    <value>false</value>
            
    </property>
            
    <property name="socketTO">
                
    <value>3000</value>
            
    </property>
        
    </bean>
        
        
    <bean id="memcachedClient" class="com.danga.MemCached.MemCachedClient">
            
    <constructor-arg>
                
    <value>neeaMemcachedPool</value>
            
    </constructor-arg>
        
    </bean>
        

    </beans>






    測試類:

    package com.abin.lee.spring.memcache;

    import org.junit.BeforeClass;
    import org.junit.Test;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;

    import com.danga.MemCached.MemCachedClient;

    public class MemcacheUtilTest {
     static MemCachedClient memcachedClient;
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {
      ApplicationContext context= new ClassPathXmlApplicationContext("com/abin/lee/spring/memcache/spring-memcache.xml");
      memcachedClient= (MemCachedClient)context.getBean("memcachedClient");
     }

     @Test
     public void test() {
      memcachedClient.set("name", "abin");
      System.out.println(memcachedClient.get("name"));
     }
    }

    posted on 2012-11-10 22:33 abin 閱讀(1355) 評論(1)  編輯  收藏 所屬分類: memcache

    Feedback

    # re: spring memcache 2013-03-04 11:53 http://www.easy518.com/
    http://www.easy518.com/  回復(fù)  更多評論
      

    主站蜘蛛池模板: 特级毛片aaaa免费观看| 亚洲欧美aⅴ在线资源| 插鸡网站在线播放免费观看| 又粗又硬又黄又爽的免费视频| 亚洲成a人无码亚洲成www牛牛| 国产色婷婷精品免费视频| 亚洲av永久无码精品秋霞电影秋| 国产裸模视频免费区无码| 阿v免费在线观看| 精品亚洲一区二区三区在线播放| 无人视频在线观看免费播放影院| 亚洲人成电影网站国产精品| 国产线视频精品免费观看视频| 国产亚洲精品资源在线26u| 无码精品一区二区三区免费视频| 亚洲精品国产第1页| 毛片视频免费观看| 美女又黄又免费的视频| 三上悠亚亚洲一区高清| 久久99精品视免费看| 亚洲制服丝袜精品久久| 午夜私人影院免费体验区| 美女被羞羞网站免费下载| 中文字幕亚洲激情| 97青青草原国产免费观看| 亚洲人成人77777在线播放| 国产午夜鲁丝片AV无码免费| 国产99视频精品免费视频76| 亚洲AV无码久久精品狠狠爱浪潮 | 亚洲精品免费在线观看| 亚洲国产成人综合| 亚洲成a人片在线观看久| 日本xxxx色视频在线观看免费| 亚洲乱码在线卡一卡二卡新区| 亚洲男女内射在线播放| 日韩插啊免费视频在线观看| 亚洲a∨无码一区二区| 亚洲国产精品无码专区在线观看| 欧美a级成人网站免费| 国产成人无码免费看片软件| 亚洲一区中文字幕在线电影网|