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

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

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

    莊周夢(mèng)蝶

    生活、程序、未來
       :: 首頁(yè) ::  ::  :: 聚合  :: 管理

    clj-xmemcached: memcached client for clojure

    Posted on 2011-10-30 13:03 dennis 閱讀(3171) 評(píng)論(0)  編輯  收藏 所屬分類: my open-sourceClojure

    clj-xmemcached

        Clj-xmemcached is an opensource memcached client for clojure wrapping xmemcached. Xmemcached is an opensource high performance memcached client for java.

    Leiningen Usage

    To include clj-xmemcached,add:

         [clj-xmemcached "0.1.1"]
    

    to your project.clj.

    Usage

    Create a client

    (use [clj-xmemcached.core])
    (def client (xmemcached 
    "host:port"))
    (def client (xmemcached 
    "host1:port1 host2:port2" :protocol "binary"))

    Then we create a memcached client using binary protocol to talk with memcached servers host1:port1 and host2:port2. Valid options including:

      :name       Client's name
      :protocol  Protocol to talk with memcached,a string value in text,binary or kestrel,default is text protocol.
      :hash          Hash algorithm,a string value in consistent or standard,default is standard hash.
      :timeout    Operation timeout in milliseconds,default is five seconds.
      :pool          Connection pool size,default is one.
    

    Store items


    (xset client "key" "dennis")
    (xset client 
    "key" "dennis" 100)
    (xappend client 
    "key" " zhuang")
    (xprepend client 
    "key" "hello,")

    The value 100 is the expire time for the item in seconds.Store functions include xset,xadd,xreplace,xappend and xprepend.Please use doc to print documentation for these functions.

    Get items

    (xget client "key")
    (xget client 
    "key1" "key2" "key3")
    (xgets client 
    "key")

    xgets returns a value including a cas value,for example:

      {:value "hello,dennis zhuang", :class net.rubyeye.xmemcached.GetsResponse, :cas 396}

    And bulk get returns a HashMap contains existent items.

    Increase/Decrease numbers


    (xincr client "num" 1)
    (xdecr client 
    "num" 1)
    (xincr client 
    "num" 1 0)

    Above codes try to increase/decrease a number in memcached with key "num",and if the item is not exists,then set it to zero.

    Delete items

    (xdelete client "num")

    Compare and set

    (xcas client "key" inc)

    We use inc function to increase the current value in memcached and try to compare and set it at most Integer.MAX_VALUE times. xcas can be called as:

     (xcas client key cas-fn max-times)

    The cas-fn is a function to return a new value,set the new value to

    (cas-fn current-value)

    Shutdown

    (xshutdown client)

    Flush

    (xflush client)
    (xflush client (InetSocketAddress. host port))

    Statistics

    (xstats client)

    Example

    Please see the example code in example/demo.clj

    License

    Copyright (C) 2011-2014 dennis zhuang[killme2008@gmail.com]

    Distributed under the Eclipse Public License, the same as Clojure.

    主站蜘蛛池模板: 亚洲情综合五月天| 日本一道一区二区免费看| 亚洲伊人久久精品影院| 人人爽人人爽人人片A免费| 亚洲精品国产高清不卡在线| 一区二区在线视频免费观看| 中文字幕亚洲综合久久菠萝蜜| 国产精品亚洲va在线观看| 国产aa免费视频| 一级女性全黄久久生活片免费| 亚洲v国产v天堂a无码久久| 一级特黄a免费大片| 亚洲中文字幕无码久久2017| a级毛片免费高清毛片视频| 亚洲色av性色在线观无码| 青青青国产在线观看免费网站| 亚洲中文字幕无码亚洲成A人片| 在线免费不卡视频| 国产精品亚洲精品日韩动图| 亚洲精品国精品久久99热| 国产婷婷成人久久Av免费高清 | 亚洲精品无码久久久久久久| 亚洲毛片在线免费观看| 在线aⅴ亚洲中文字幕| 免费一级特黄特色大片在线 | 亚洲综合国产一区二区三区| 日本视频在线观看永久免费| 亚洲高清中文字幕| 国产免费人成在线视频| 国产真人无码作爱免费视频| 亚洲国产视频网站| 亚洲av手机在线观看| a级毛片毛片免费观看久潮喷| 亚洲日韩中文字幕天堂不卡| 日本特黄特色免费大片| 国产在线观看免费av站| 亚洲欧洲国产成人精品| 亚洲国产精品毛片av不卡在线 | 国产亚洲视频在线播放| 美女视频黄a视频全免费| 男女作爱免费网站|