How to get started with Memcached C #

Source: Internet
Author: User

MemcachedIt is an open-source high-performance distributed cache component and has been widely used in various Internet fields. client Development kits with multiple languages, including Perl/PHP/JAVA/C/Python/Ruby/C #/MySQL. this site is already using YouTube, Reddit, Zynga, Facebook, Orange. view
The following figure compares the image.

 

It is also a platform for expansion. Today we are looking at the server under windows and the client using. net to access it.
Select the client Enyim Memcached.
First, we install the windows server. You can download it from this site. Run the following command to install it:

Memcached.exe-d install

In this way, create a memcached service in Windows service. You can also use-d uninstall to uninstall it. The default listening 11211 will be used during runtime.
IP: 127.0.0.1, as shown in:

Create a console program to reference Enyim. Caching. dll, and in the configuration file:

   1:  <configuration>
   2:    <configSections>
   3:      <sectionGroup name="enyim.com">
   4:        <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching"/>
   5:      </sectionGroup>
   6:    </configSections>
   7:    <enyim.com>
   8:      <memcached protocol="Binary">
   9:        <servers>
  10:          <add address="127.0.0.1" port="11211"/>
  11:        </servers>
  12:      </memcached>
  13:    </enyim.com>
  14:    </configuration>

Test:

   1:              using (var mc = new MemcachedClient())
   2:              {
   3:                  mc.Store(StoreMode.Set, "mytime", DateTime.Now.ToString());
   4:                  string temp = mc.Get<string>("mytime");
   5:   
   6:                  Console.Write(temp);
   7:                  Console.Read();
   8:              }
 
I hope this article will be helpful for your development.

Author: Petter Liu
Source: http://www.cnblogs.com/wintersun/
The copyright of this article is shared by the author and the blog Park. You are welcome to repost this article. However, you must retain this statement without the author's consent and provide a clear link to the original article on the article page. Otherwise, you will be held legally liable.
This article is also published in Petter Liu Blog, my independent Blog.

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.