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

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

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

    重復容易,改變很難
    java,,,不錯的玩具
    posts - 21,  comments - 42,  trackbacks - 0
    使用java調用memcache,獲取數據
     1,下載客戶端
          下載java客戶端API,實際上是一個jar包。
        http://www.danga.com/memcached/apis.bml
        memcache支持很多種客戶端調用如:Perl、php、python、Ruby、java、C#、C等等
        在java中目前支持兩種客戶端“Java API for memcached”和“Improved Java API for memcached”
        我用的是前者,因為它有詳細的說明文檔
       
        下載http://img.whalin.com/memcached/jdk6/standard/java_memcached-release_2.0.1.jar

     2,開始用java程序調用memcached   
      

    在eclipse中新建一個工程,將上面下載的java_memcached-release_2.0.1.jar引入工程。
          新建java類memcachedTest
        import com.danga.MemCached.MemCachedClient;
    import com.danga.MemCached.SockIOPool;


    public class memcachedTest {
     // create a static client as most installs only need
     // a single instance
     protected static MemCachedClient mcc = new MemCachedClient();
     
     //連接memcache
     static{
      
      // set up connection pool once at class load
      // server list and weights
      String[] servers =
       {
            "192.168.0.20:11211",
         "192.168.0.20:11212"
       };

      Integer[] weights = { 3,2 };

      // grab an instance of our connection pool
      SockIOPool pool = SockIOPool.getInstance();

      // set the servers and the weights
      pool.setServers( servers );
      pool.setWeights( weights );

      // set some basic pool settings
      // 5 initial, 5 min, and 250 max conns
      // and set the max idle time for a conn
      // to 6 hours
      pool.setInitConn( 5 );
      pool.setMinConn( 5 );
      pool.setMaxConn( 250 );
      pool.setMaxIdle( 1000 * 60 * 60 * 6 );

      // set the sleep for the maint thread
      // it will wake up every x seconds and
      // maintain the pool size
      pool.setMaintSleep( 30 );

      // set some TCP settings
      // disable nagle
      // set the read timeout to 3 secs
      // and don't set a connect timeout
      pool.setNagle( false );
      pool.setSocketTO( 3000 );
      pool.setSocketConnectTO( 0 );

      // initialize the connection pool
      pool.initialize();


      // lets set some compression on for the client
      // compress anything larger than 64k
      mcc.setCompressEnable( true );
      mcc.setCompressThreshold( 64 * 1024 );
      
      
     }
     public static void main(String[] a){
      for(int i=0;i<1000;i++){
          mcc.set( "Test_"+i, "hello world_"+i);
      }
      //第一次運行講一下三行注釋,用以上面三行進行數據插入,以后運行就將上面三行注釋,運行下面三行語句來看執行效果。

      System.out.println("dd1="+(String)mcc.get( "Test_967"));
      System.out.println("dd2="+(String)mcc.get( "Test_984"));
      System.out.println("dd3="+(String)mcc.get( "Test_981"));
      
      System.out.println("End"); 
     }

    }

    網上參考資料:
        http://bbs.linuxpk.com/thread-13497-1-1.html
        http://www.ccvita.com/257.html
        http://www.danga.com/memcached/apis.bml
        http://www.whalin.com/memcached/   

    posted on 2008-10-10 11:34 分享愛的空間 閱讀(2423) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(5)

    隨筆檔案

    文章檔案

    相冊

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: jizz18免费视频| 一级特黄录像视频免费| 99re免费在线视频| 亚洲AV无码不卡在线播放| 国内精品久久久久影院免费| 精品亚洲综合在线第一区| 91视频精品全国免费观看| 国产亚洲精品xxx| 国产精成人品日日拍夜夜免费| 亚洲av日韩av激情亚洲| 在线观看免费av网站| 亚洲国产模特在线播放| 女人18毛片a级毛片免费视频| 亚洲精品自偷自拍无码| 亚洲国产精品自产在线播放 | 亚洲综合av一区二区三区不卡| 国产99视频精品免费观看7| 亚洲国产欧美一区二区三区| 国产免费观看a大片的网站| 一个人免费观看视频在线中文| 亚洲国产精品高清久久久| 免费视频爱爱太爽了| 亚洲αⅴ无码乱码在线观看性色| 又爽又高潮的BB视频免费看| 中文字幕av免费专区| 亚洲伊人久久大香线焦| 热99re久久免费视精品频软件 | 午夜亚洲WWW湿好爽| 毛茸茸bbw亚洲人| 91精品免费观看| 久久久久亚洲精品无码网址色欲| 国产成人99久久亚洲综合精品| 久久免费视频精品| 亚洲欧美日韩中文高清www777| 亚洲一区二区三区无码影院| 在线人成精品免费视频| 国产亚洲精品国产福利在线观看 | 韩国日本好看电影免费看| 国产在线精品一区免费香蕉 | 国产精品亚洲产品一区二区三区| 24小时免费看片|