That dot so-called distributed--memcache

Source: Internet
Author: User
Tags delete cache

This is the beginning of the decision to change the name of the series of articles, think of a good name, it is not to play a standalone version of the line.

Well, let's take a look at a non-persistent cache server Memcache, when it comes to caching instinct reflection is cache,session or something, yes, that

Some are based on the. NET process, the popular point also can not do multi-machine sharing, the typical one is SSO.

One: Installation

Memcahce like Redis,mongodb need to open their own server, we download Memcached_1.2.5.zip, and then put on the C drive, modify the file

Name is memcached.

1:install

Install can be said to be universal command, first we go to the memcached directory, and then memcached.exe-d install.

2:start

Now all we have to do is start start, and note that the default port of Memecache is 11211, and I don't want to re-specify the port.

3:stop,uninstall

These two will not, one is to stop, one is to unload, anyway is universal command.

II: Driver

Memcache server We are already open, because in the company has been in the recent use of PHP, forget it or C # driver, who let this is. Net

Community, download C # driver, since it is a cache server, as long as there is a basic curd, I think it should be almost.

 1 using System; 2 using System.Collections.Generic; 3 4 Namespace beit.memcached 5 {6 class Example 7 {8 public static void Main (string[] args) 9 { 10//Initialize Memcache instance by configuration file Memcachedclient cache = memcachedclient.getinstance ("Myconfigfilecache" ); 12 13//edit (can simulate session operation, cache 20 minutes) cache. Set ("name", "Line Code Farm", DateTime.Now.AddMinutes (20)); 15 16//Get the var result = cache. Get ("name"); Console.WriteLine ("Gets the cache data for name:" + result); 20 21//delete cache. Delete ("name"), Console.WriteLine ("\ n successfully deleted the data for name in cache"), and result = cache. Get ("name"); Console.WriteLine ("\ n get the data for name in the cache again:" + (result??).  "NULL") + "\ n"); 29 30//View the operation of the Memecahce. foreach (Keyvaluepair<string, dictionary<string, String>> host in cache. Status ()). {Console.Out.WriteLine ("HoST: "+ host. Key); keyvaluepair<string, string> item in host. Value) {Console.Out.WriteLine ("\ T" + Item). Key + ":" + Item.         Value);}38 Console.Out.WriteLine ();}40 Console.read (); 42 }43}44}

We define the configuration file, since memcache can be used for distribution, it will not be able to allocate the cache to several servers, you can see, the following

Configuration is also very simple, of course, the law of distribution is naturally memcache its own algorithm decision, and finally do not forget to open a port on another server on it

On the line.

<?xml version= "1.0" encoding= "Utf-8"?><configuration>  <configSections>    <section Name = "beitmemcached" type= "System.Configuration.NameValueSectionHandler"/>  </configSections>  < appsettings>  </appSettings>  <beitmemcached>    <add key= "Myconfigfilecache" value= " 127.0.0.1:11211 "/>    <!--<add key=" Myconfigfilecache "value=" 127.0.0.1:11211,127.0.0.1:8888 "/>-- >  </beitmemcached></configuration>

Here is the packager: beitmemcached, you can also go to Codegoogle to download

That dot so-called distributed--memcache

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.