Distributed Cache Memcached Learning

Source: Internet
Author: User

One. Install the server:

Service side: Http://code.jellycan.com/files/memcached-1.2.6-win32-bin.zip

64:http://blog.couchbase.com/memcached-windows-64-bit-pre-release-available

1. Unzip the file to C:\memcached

2. Command line input ' c:\memcached\memcached.exe-d install '

3. Command line input ' c:\memcached\memcached.exe-d start ', the command starts memcached, the default listener port is 11211
You can view its help through memcached.exe-h

Problems with the installation may occur:

If the problem occurs:

There are 1 scenarios where you can find the Cmd.exe right-click Administrator to run.

2 is going to service there to see if it's already installed

Two. Download the client

Client: http://sourceforge.net/projects/memcacheddotnet/

e:\memcached\memcached.exe-d Install

Three. Use

1. Place the Commons.dll,icsharpcode.sharpziplib.dll,log4net.dll,memcached.clientlibrary.dll in the bin directory
2. Quoting Memcached.ClientLibrary.dll

Code:

Using system;using Memcached.clientlibrary;namespace membercache{class Program {static void Main (string[] A            RGS) {string[] serverlist = {"127.0.0.1:11211", "127.0.0.1:11211"};            Initialize pool Sockiopool pond = 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 ();            Get the client instance memcachedclient mc = new Memcachedclient (); Mc.            EnableCompression = false;            Console.WriteLine ("------------Test-----------"); Mc.  Set ("Test", "my Value"); Stores the data to the cache server, where the string "My value" is cached, and the key is "test" if (MC. Keyexists ("test"))//test cache exists key test for project {COnsole.                WriteLine ("Test is Exists"); Console.WriteLine (MC. Get ("Test").  ToString ());            Gets the item with the key test in the cache} else {Console.WriteLine ("Test Not Exists");            } console.readline (); Mc.  Delete ("test"); Removes the item if (MC) of the key test in the cache.                Keyexists ("test")) {Console.WriteLine ("Test is Exists"); Console.WriteLine (MC. Get ("Test").            ToString ());            } else {Console.WriteLine ("Test Not Exists");            } console.readline (); Sockiopool.getinstance ().        Shutdown (); }    }}

Operation Result:

Finally: Write bad, see the uncomfortable you come to hit me.

Distributed Cache Memcached Learning

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.