Thank you very much for csdn and the cold Moon. The Lord made me quickly learn. NET Operations Memcache article from: http://download.csdn.net/detail/e_wsq/4358982
Example 1 of C # access Memcache put Commons.dll,icsharpcode.sharpziplib.dll,log4net.dll,memcached.clientlibrary.dll in bin directory 2 Reference Memcached.ClientLibrary.dll
1 string[] ServerList = {"127.0.0.1:11211","90.0.12.120:11211" };2 3 //Initialize Pool4Sockiopool pool =sockiopool.getinstance ();5 pool. Setservers (serverlist);6 7Pool. Initconnections =3;8Pool. Minconnections =3;9Pool. MaxConnections =5;Ten OnePool. Socketconnecttimeout = +; APool. Sockettimeout = the; - -Pool. Maintenancesleep = -; thePool. Failover =true; - -Pool. Nagle =false; - pool. Initialize (); + - //get the client instance +memcachedclient MC =Newmemcachedclient (); AMc. EnableCompression =false; at -Console.WriteLine ("------------Test-----------"); -Mc. Set ("test1","This is test");//stores the data to the cache server, where the string "My value" is cached, and key is "test" - - if(MC. Keyexists ("Test"))//test cache has a project with key test - { inConsole.WriteLine ("the value of key for test is correctly written"); -Console.WriteLine ("the value of test is:"+MC. Get ("Test"). ToString ());//get the item with key test in the cache to } + Else - { theConsole.WriteLine ("Test not Exists"); * } $ Panax Notoginseng //console.readline (); - vartt = MC. Get ("Test"); the //MC. Delete ("test"); //Remove the item in the cache with key test + A if(MC. Keyexists ("Test")) the { +Console.WriteLine ("test is Exists"); -Console.WriteLine (MC. Get ("Test"). ToString ()); $ } $ Else - { -Console.WriteLine ("value has been deleted"); the } - //console.readline ();Wuyi theSockiopool.getinstance (). Shutdown ();//Close the pool, close sockets
View Code
. NET Memcache