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