. NET app memcached cache demo (non-reprinted, file download address valid)

Source: Internet
Author: User
Tags rar ukey

First, Prepare:

memcaced Service side: Http://files.cnblogs.com/sjns/memcached_en32or64.rar

Memcaced Client class Library: Http://files.cnblogs.com/sjns/Memcached.ClientLibrary.rar

Which service the detection data is saved in: SECURECRT (note: This software has not been used, this is only recorded later in the verification of time)

Second, install the memcaced service end

Copy the Memcached.exe to any directory. Install with the cmd command. ( Note: Run command prompt again under Win7 to run with administrative identity )

Installation: memcached.exe-d Install

Start: memcached.exe-d start

Uninstall: memcached.exe-d Uninstall

Third, create the program, I use the console application here.

Add the Memcaced client class library to the reference.

    

Sockiopool is a socket connection pool provided by the memcached client, which, in layman's words, is the object that exchanges data with the memcached server side.

Note: Sockiopool is initialized at the start of the application, and we can put this job on GLOBAL. ASAX. CS in the Application_Start method.

Okay, here's my Code, a demo.

  

Static voidMain (string[] args) {            Char[] Separator = {',' }; string[] ServerList =New string[] {"127.0.0.1:11211" };            Try{Sockiopool Pool=sockiopool.getinstance (); Pool.                Setservers (serverlist); Pool. Initconnections=3; Pool. Minconnections=3; Pool. MaxConnections= -; Pool. Socketconnecttimeout= +; Pool. Sockettimeout= the; Pool. Maintenancesleep= -; Pool. Failover=true; Pool. Nagle=false; Pool.                Initialize (); Memcachedclient MC=Newmemcachedclient (); Mc. Set ("123","123123123"); Console.WriteLine ("enter the key to query"); stringKey =Console.ReadLine (); Console.WriteLine (MC.                Get (key)); Console.WriteLine ("enter the key to be modified"); String Ukey=Console.ReadLine (); Console.WriteLine ("Enter the value to modify"); String Uval=Console.ReadLine (); Console.WriteLine (MC.                Set (Ukey, uval)); Console.WriteLine ("Key:"+ Ukey +"The value has been modified. as follows:"); Console.WriteLine ("Value:"+uval); }            Catch(Exception err) {//Here you can record the error with Log4net!             }        }

Here's how it works:

. NET app memcached cache demo (non-reprinted, file valid)

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.