部署緩衝系統Memcached解決方案

來源:互聯網
上載者:User

 

伺服器上的軟體安裝:

路徑/memcached.exe -d install
路徑/memcached.exe -d start

 

memcached的其他配置:

-p 監聽的連接埠
-l 串連的IP地址, 預設是本機
-d start 啟動memcached服務
-d restart 重起memcached服務
-d stop|shutdown 關閉正在啟動並執行memcached服務
-d install 安裝memcached服務
-d uninstall 卸載memcached服務
-u 以的身份運行 (僅在以root啟動並執行時候有效)
-m 最大記憶體使用量,單位MB。預設64MB
-M 記憶體耗盡時返回錯誤,而不是刪除項
-c 最大同時串連數,預設是1024
-f 塊大小增長因子,預設是1.25
-n 最小分配空間,key+value+flags預設是48
-h 顯示協助

 

程式測試(對測試的項目引用Enyim.Caching.dll)

針對配置的應用測試組態App.config和web上Web.config

中的configuration項中添加:

<sectionGroup name="enyim.com">

      <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching"/>

    </sectionGroup>

    <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching"/>

  </configSections>

  <enyim.com>

    <memcached>

      <servers>

<!--服務端的地址-->

        <add address="192.168.0.3" port="11211"/>

        <add address="192.168.0.5" port="11211"/>

      </servers>

      <socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:00:10" deadTimeout="00:02:00"/>

    </memcached>

  </enyim.com>

  <memcached keyTransformer="Enyim.Caching.TigerHashTransformer, Enyim.Caching">

    <servers>

      <add address="192.168.0.3" port="11211"/>

      <add address="192.168.0.5" port="11211"/>

    </servers>

    <socketPool minPoolSize="2" maxPoolSize="100" connectionTimeout="00:00:10" deadTimeout="00:02:00"/>

  </memcached>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>

 

代碼中:

MemcachedClient mc = new MemcachedClient();//建立對象

 

mc.Store((StoreMode.Set,"key",value)//value一個object對象

mc.Remove(key)//刪除操作

mc.Get(key)//擷取資料對象。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.