Introduction to memcached development in Windows 7 and net4

Source: Internet
Author: User

Environment preparation:

1. download and install the memcached server for Windows:

:

Http://www.splinedancer.com/memcached-win32/

Installation Method After download:

Decompress the ZIP file to a directory, such as D: \ dB \ memcached. the following file name is memcached.exe.

Start cmd as an administrator and go to the decompressed directory. In this example, D: \ dB \ memcached and run the following command:

// Install memcached as a Windows Service

Memcached.exe-D install

// Start the service and listen to port 11211 of the Local Computer

Memcached.exe-l localhost-P 11211-d start

 

2. Download nmemcached. Client ------ memcached client for C.

:

Http://nmemcached.codeplex.com/

 

3. Create an app (console, winform, or web) and Add a reference to nmemcached. Client. dll.

3.1 Add the memcached configuration information in APP. config (or web. config) of the app, for example:

<Configsections> <section name = "nmemcached. client "type =" nmemcached. client. configuration. nmemcachedconfigurationsection, nmemcached. client "/> </configsections> <startup> <supportedruntime version =" v4.0 "SKU = ". netframework, version = v4.0 "/> </startup> <nmemcached. client useutc = "false"> <connectionprovider> <Add Server = "127.0.0.1" Port = "11211"> </Add> </connectionprovider> </nmemcached. client>
 
 
 3.2 compiling example  Code :
Using (VAR client = nmemcached. client. memcachedclient. create () {client. connectionerror + = new system. eventhandler <nmemcached. client. connectioneventargs> (client_connectionerror); client. flushall (); string key = "key1"; student s = new student () {name = "zhaoy", age = 111}; responsecode resp = client. set (key, S, datetime. now. addminutes (10); object keyval = client. get (key); console. writeline (resp. tostring (); console. writeline (keyval);} // using

 

4. Connect to memcached through command line

4.1 for Windows 7, you must enable the Telnet client first.

4.2 open the CMD command line and enter the following command to connect to memcached:

Telnet fig 11211

Enter

Then you can run the following command to interact with memcached:

1, stats

Enter

// Description: Lists common memcached information, such as the space used and cache items.

2, set key1 0 0 8

Enter

12345678

Enter

// Description: The write key is key1, the value is 12345678, and key1 is the key name.

For command instructions, see the followingArticle:

Http://www.cnblogs.com/jeffwongishandsome/archive/2011/11/06/2238265.html

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.