Learning memcached:2 Basic Application console use

Source: Internet
Author: User
Tags memcached

1. First create a new console app.

2. Import the DLL that will download the memcached that you want to reference.

3. Pre-preparation work is over, in fact very simple, memcache configuration use is quite simple. Here is the code to write.

1 usingmemcached.clientlibrary;2 usingSystem;3 usingSystem.Collections.Generic;4 usingSystem.Linq;5 usingSystem.Text;6 usingSystem.Threading.Tasks;7 8 namespaceMemcacheddemo9 {Ten     class Program One     { A         Static voidMain (string[] args) -         { -             string[] Servers = {"127.0.0.1:11211"}; the  -             //Initialize Pool -Sockiopool pool =sockiopool.getinstance (); - pool. Setservers (servers); +Pool. Initconnections =3;//number of initialized links -Pool. Minconnections =3;//To set the connection pool minimum number of connections +Pool. MaxConnections =5;//Set Connection pool maximum connection number APool. Sockettimeout = +;//socket processing time is the time-out period atPool. Maintenancesleep = -;//set the sleep time for a thread -Pool. Failover =true;//set the fault flag for the Sockio pool -Pool. Nagle =false;//set whether to use the Nagle algorithm -Pool. Initialize ();//true Initialization -  -memcachedclient MC =NewMemcached.ClientLibrary.MemcachedClient ();//Client Instance inMc. EnableCompression =false;//Whether compression is enabled -  to             //Insert Key:test, value: The data of this is Test +Mc. ADD ("Test","This is test"); -              the             //Query the key:test data and print it out *             stringstr = MC. Get ("Test"). ToString (); $Console.WriteLine ("the value of test is:"+str);Panax Notoginseng Console.readkey (); -         } the     } +}

Execution results

This is how the console is used.

PS: This article is for the author's own study to consolidate.

Learning memcached:2 Basic Application console use

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.