- Tools:
- Memcached-1.2.6-win32-bin.zip memcached Service-side program (for Win)
- Memcached manager Win's Memcached management tool
- Memcached. NET client Library c#/.net Memcached clients DLL
- Installation Configuration memcached Service side
- Download Memcached-1.2.6-win32-bin.zip, extract Memcached.exe, is memcached the main program. For example, we put it under C:\Program files\memcached under the memcached server.
- Download and install Memcached Manager to manage the memcached server.
Open memcached Manager and click Add Server to fill in the server information. I have installed the memcached directly here locally. , click Apply after filling, the server will appear on the right side of successful words.
Click Add instance to append the memcached instance. Here are some configuration information. Ip, port, memory and so on, not explained. Click Apply will prompt you to start now, we choose here is
After success found that there are already instances on the right side, to this server configuration is complete.
- Client Calls
- The first thing you need to do is download the memcached. NET client Library, unzip it to get a memcacheddotnet directory, a bunch of files.
To test memcached, we build a Web project. Reference Memcached.ClientLibrary.dll, this dll in Memcacheddotnet\trunk\clientlib\src\clientlib\bin\2.0\release
- Use is relatively simple, 1 storage, 1 fetch. Let's simply get two pages.
Plus using
Using Memcached.clientlibrary;
Save:
Code:
protected void Page_Load (object sender, EventArgs e)
{
if (! IsPostBack)
{
String[] serverlist = {server. Text};
Sockiopool pool = sockiopool.getinstance ();
Pool. Setservers (serverlist);
Pool. Initconnections = 3;
Pool. Minconnections = 3;
Pool. MaxConnections = 5;
Pool. socketconnecttimeout = 1000;
Pool. Sockettimeout = 3000;
Pool. Maintenancesleep = 30;
Pool. Failover = true;
Pool. Nagle = false;
Pool. Initialize ();
}
}
protected void Setvalue_click (object sender, EventArgs e)
{
memcachedclient mc = new Memcachedclient ();
Mc. EnableCompression = false;
Mc. Set (Key.text, Value.text);
Response.Write ("<script>alert (' OK ') </script>");
}
Take:
Code:
protected void Getvalue_click (object sender, EventArgs e)
{
String[] serverlist = {server. Text};
Sockiopool pool = sockiopool.getinstance ();
Pool. Setservers (serverlist);
Pool. Initconnections = 3;
Pool. Minconnections = 3;
Pool. MaxConnections = 5;
Pool. socketconnecttimeout = 1000;
Pool. Sockettimeout = 3000;
Pool. Maintenancesleep = 30;
Pool. Failover = true;
Pool. Nagle = false;
Pool. Initialize ();
memcachedclient mc = new Memcachedclient ();
Mc. EnableCompression = false;
String value = (String) mc. Get (Key.text);
Value.text = value;
}
Look at the effect:
Click Add to save to memcached
Point get. Get the results.
Transferred from: http://www.cnblogs.com/weberypf/archive/2011/02/18/1957937.html
Under Windows configuration using memcached