Memcached windows 下安裝與測試

來源:互聯網
上載者:User

   Memcached 是一個高效能的分布式記憶體對象緩衝系統,用於動態Web應用以減輕資料庫負載。它通過在記憶體中快取資料和對象來減少讀取資料庫的次數,從而提供動態、資料庫驅動網站的速度。Memcached基於一個儲存鍵/值對的hashmap。其守護進程(daemon )是用C寫的,但是用戶端可以用任何語言來編寫,並通過memcached協議與守護進程通訊。但是它並不提供冗餘(例如,複製其hashmap條目);當某個伺服器S停止運行或崩潰了,所有存放在S上的鍵/值對都將丟失。

Memcached官方:http://danga.com/memcached/

關於Memcached的介紹請參考:Memcached深度分析

下載Windows的Server端

下載地址:http://code.jellycan.com/memcached/

安裝Memcache Server(也可以不安裝直接啟動)

1. 下載memcached的windows穩定版,解壓放某個盤下面,比如在c:\memcached
2. 在CMD下輸入 "c:\memcached\memcached.exe -d install" 安裝.
3. 再輸入:"c:\memcached\memcached.exe -d start" 啟動。NOTE: 以後memcached將作為windows的一個服務每次開機時自動啟動。這樣伺服器端已經安裝完畢了。

如果下載的是二進位的版本,直接運行就可以了,可以加上參數來加以設定。


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

然後就可以用.net 的memcached用戶端來試一下了。

C# 下可用的API(每個用戶端API中都有詳細的說明和注釋)

https://sourceforge.net/projects/memcacheddotnet/
http://www.codeplex.com/EnyimMemcached/ - Client developed in .NET 2.0 keeping performance and extensibility in

mind. (Supports consistent hashing.) 
http://code.google.com/p/beitmemcached/ - Client developed by BeIT with many new features

轉載出處: http://www.yaosansi.com/

----------------------------------------------------------------------------------------

Client調用:

下載範例程式碼網址: http://sourceforge.net/projects/memcacheddotnet/

C#/.NET memcached client library. This library can be used by .NET projects to access memcached servers. Ported from the Java memcached library located athttp://www.whalin.com/memcached/.

e.g.: view source print ?

001 /**
002  * MemcachedBench.cs
003  *
004  * Copyright (c) 2005
005  * Tim Gebhardt <tim@gebhardtcomputing.com>
006  *
007  * Based off of code written by
008  * Greg Whalin <greg@meetup.com>
009  * for his Java Memcached client:
010  * http://www.whalin.com/memcached/
011  *
012  *
013  * See the memcached website:
014  * http://www.danga.com/memcached/
015  *
016  * This module is Copyright (c) 2005 Tim Gebhardt.
017  * All rights reserved.
018  *
019  * This library is free software; you can redistribute it and/or
020  * modify it under the terms of the GNU Lesser General Public
021  * License as published by the Free Software Foundation; either
022  * version 2.1 of the License, or (at your option) any later
023  * version.
024  *
025  * This library is distributed in the hope that it will be
026  * useful, but WITHOUT ANY WARRANTY; without even the implied
027  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
028  * PURPOSE.  See the GNU Lesser General Public License for more
029  * details.
030  *
031  * You should have received a copy of the GNU Lesser General Public
032  * License along with this library; if not, write to the Free Software
033  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
034  *
035  * @author Tim Gebhardt<tim@gebhardtcomputing.com>
036  * @version 1.0
037  */
038 namespace Memcached.MemcachedBench
039 {
040     using System;
041     using System.Collections;
042  
043     using Memcached.ClientLibrary;
044  
045     public class MemcachedBench
046     {
047         /// <summary>
048         /// Arguments:
049         ///     arg[0] = the number of runs to do
050         ///     arg[1] = the run at which to start benchmarking
051         /// </summary>
052         /// <param name="args"></param>
053         [STAThread]
054         public static void Main(String[] args)
055         {
056             int runs = 100;
057             int start = 200;
058             if(args.Length > 1)
059
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.