1 Install libevent ubuntu:apt-get Install name Suse:yast2-i name Centos:yum install name
2 Install memcached ubuntu:apt-get install name Suse:yast2-i name Centos:yum install name
3 Start the service (similar to the socket open listening, check whether the open is good, PS ef|grep memcache or netstat)
4 the necessary configuration of the client (dependencies, connectstring, etc. (shown here on the diagram below)), to prepare the communication based on the configuration on-demand connection.
Completed above: Test
1: Build WinForm App
2 Assume that the layout is as follows, two labels, two textbox, and a button.
3: Double-click the button and add the following code (note the DLL reference and namespace added in step fourth)
private void Btngetvalue_click (object sender, EventArgs e)
{
String[] serverlist = {Txtserver.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 (Txtkey.text);
MessageBox.Show (value);
}
4: Run, enter the memched server IP and memcached corresponding port number, (Key:value also has the use of similar set get)
My summary: Imitation, customization, adapting to the new requirements. This and MySQL for. NET process is almost a mold.
There is a pattern of wood found a law, mysql-server,redis-server,*-server, one to the other *-client (the client has a manual input command terminal, has a shell GUI, has coded connection app, the essence, all the same, socket communication)
C # using the Memcached sample