1. If you use the official method, you have configured parameters and Server IP addresses in web. config. For example:
<?xml version=?><configuration> <configSections> <sectionGroup name=> <section name= type=/> </sectionGroup> <section name= type= /> </configSections> <enyim.com> <memcached protocol=> <servers> <add address= port= /> <add address= port= /> <add address= port= /> <add address= port= /> </servers> <socketPool minPoolSize= maxPoolSize= connectionTimeout= deadTimeout= /> </memcached> </enyim.com> <system.web> <compilation debug= targetFramework=/> </system.web></configuration>
You can use this generic class to automatically call the configuration in web. config.
Add cache AddCache (key, (MemcachedClient mc = add cache AddCache (key, value, (MemcachedClient mc = get the cache GetCache (MemcachedClient mc = whether the cache IsExists (MemcachedClient mc = mc. get (key )! = Delete cache (false if the key does not exist) DelCache (MemcachedClient mc = clear cache (MemcachedClient mc =View Code 2. If you do not want to configure web. config, use the following generic class. Create Memcache client MemcachedClient CreateServer (List <IPEndPoint> = MemcachedClientConfiguration (); (I =; I <serverList. count; I ++ System. net. IPEndPoint (IPAddress. parse (serverList [I]. address. toString (), serverList [I]. port); = (PlainTextAuthenticator); config. authentication. parameters [] =; config. authentication. parameters [] =; MemcachedClient mac = MemcachedClient (config); add cache AddCache (List <IPEndP Oint> serverList, key, (MemcachedClient mc = add cache AddCache (List <IPEndPoint> serverList, key, value, (MemcachedClient mc = get cache GetCache (List <IPEndPoint> serverList, (MemcachedClient mc = whether the cache IsExists (List <IPEndPoint> serverList, (MemcachedClient mc = mc. get (key )! = Delete cache (if the key does not exist, false is returned) DelCache (List <IPEndPoint> serverList, (MemcachedClient mc = clear cache FlushCache (List <IPEndPoint> (MemcachedClient mc =View Code