C # using the Memcached sample

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.