Configure memcached in Windows

Source: Internet
Author: User
Tags memcached manager
    • tool:
      • memcached-1.2.6-win32-bin.zip memcached server Program (For Win)
      • memcached manager memcached management tool in win
      • memcached. net client library C #/. net memcached client DLL
    1. install and configure the memcached Server
      1. download the memcached-1.2.6-win32-bin.zip file and decompress it to get memcached.exe, which is the main program of memcached. For example, we put it under c: \ Program Files \ memcached on the memcached server.
      2. download and install memcached manager to manage the memcached server.

        open memcached manager, click Add Server, and enter the server information. I have installed memcached locally ., After filling in the fields, click Apply. If successful, the server will appear on the right.

        click Add instance to add a memcached instance. Here are some configuration information. IP address, port, memory, and so on. After you click Apply, you will be prompted if you are starting now. Here we select

        . After successful, an instance is found on the right, the server configuration is complete.

    2. client call
      1. first download memcached. net client library client class library, decompress it to obtain a memcacheddotnet directory with a bunch of files.

      to test memcached, we create a web project. Reference memcached. clientlibrary. dll. This dll is stored in memcacheddotnet \ trunk \ clientlib \ SRC \ clientlib \ bin \ 2.0 \ release

      1. it is easy to use, with one memory and one fetch. Let's get two simple pages.

        Add using

UsingMemcached. clientlibrary;

 

Storage:

 

Code:


Protected
VoidPage_load (ObjectSender,EventargsE)

{


If(! Ispostback)

{


String[] Serverlist = {server. Text };


SockiopoolPool =Sockiopool. Getinstance ();

Pool. setservers (serverlist );

Pool. initconnections = 3;

Pool. minconnections = 3;

Pool. maxconnections = 5;

Pool. socketconnecttimeout = 1000;

Pool. Fig = 3000;

Pool. maintenancesleep = 30;

Pool. Failover =True;

Pool. Nagle =False;

Pool. initialize ();

}

}


Protected
VoidSetvalue_click (ObjectSender,EventargsE)

{


MemcachedclientMC =New
Memcachedclient();

MC. enablecompression =False;

MC. Set (key. Text, value. Text );

Response. Write ("<SCRIPT> alert ('OK') </SCRIPT>");

}

 

 

Take:

Code:

Protected
VoidGetvalue_click (ObjectSender,EventargsE)

{


String[] Serverlist = {server. Text };


SockiopoolPool =Sockiopool. Getinstance ();

Pool. setservers (serverlist );

Pool. initconnections = 3;

Pool. minconnections = 3;

Pool. maxconnections = 5;

Pool. socketconnecttimeout = 1000;

Pool. Fig = 3000;

Pool. maintenancesleep = 30;

Pool. Failover =True;

Pool. Nagle =False;

Pool. initialize ();


MemcachedclientMC =New
Memcachedclient();

MC. enablecompression =False;


StringValue = (String) MC. Get (key. Text );

Value. Text = value;

}

 

 

See the results:

 

Click Add to save to memcached.

 

 

Click get. The result is displayed.

 

 

OK. You can also encapsulate the client code to make the call easier.

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.