Quick Start Guide to Using memcached in ASP. NET Environment

Source: Internet
Author: User
Tags memcached windows

I have been trying to study memcached for a while, so that my current ASP. Net Attack case can solve the problem that the cache on multiple hosts is not synchronized,
I don't think it takes much time to get started, so I made some notes.

Server guard memcached (ver 1.4.4) for Win32

1. Disable memcached 1.4.4 windows 32-bit binary or memcached windows 64-bit pre-release.

Http://www.urielkatz.com/archive/detail/memcached-64-bit-windows/

Wind32:

Http://jehiah.cz/projects/memcached-win32/

Win64:

Http://www.urielkatz.com/projects/memcached-win64/memcached-win64.zip

 

 

Http://jehiah.cz/projects/memcached-win32/

--

2. Create a file in c: \ Program FilesMemcachedContents

3. Resolve the lower-level worker nodesC: \ Program Files \ memcachedContents

4. Open a ticketCommand Prompt character (Remember to run win2008/win7 as an administrator)

5. Import memcached into Windows Server

 
"C: \ Program Files \ memcached \ memcached.exe"-D install

6. Activate memcached Service

 
"C: \ Program Files \ memcached \ memcached.exe"-D start

Remove memcached (ver 1.4.4) for Win32

1. Open a ticketCommand Prompt character

2. Stop the memcached Service

 
"C: \ Program Files \ memcached \ memcached.exe"-D stop

3. Remove memcached from Windows Server

 
"C: \ Program Files \ memcached \ memcached.exe"-D uninstall

4. Remove the c: \ Program Files \ memcached category

Whether zookeeper memcached works properly

1. Connect to the 11211 port of localhost through the Telnet command, where port 11211 is
Listen port. If the firewall is enabled, remember to set the port so that the terminal can be connected. (Configure all listen interfaces)

 
Telnet local host 11211

2. Execute the stats command and press enter to obtain the current memcached server's operational role. If there is information, it indicates that the security is successful.

3. Run the quit command and press enter to exit.

Zookeeper: Complete instructions. Please refer to memcached protocol.

Set ASP. NET Protocol

1. Disable memcached providers ==> memcached
Providers 1.2 (. NET 3.5)

2. Upload the following components to the bin directory of the ASP. NET Website, or throughJoin the exam(Add
Reference
) Method to be added to the ticket

    • Enyim. caching. dll
    • Enyim. caching. PDB
    • Memcachedproviders. dll
    • Memcachedproviders. PDB

Set memcached cached provider and redirect to Web. config

1. Add the following definitions in the <configsections> section:

<! -- Memcached -->  <  Section   Name  = "Cacheprovider"       Type  = "Memcachedproviders. cache. cacheprovidersection, memcachedproviders"      Allowdefinition  = "Machinetoapplication"   Restartonexternalchanges  = "True"  />      <  Sectiongroup   Name  = "Enyim.com"  >    < Section   Name  = "Memcached"        Type  = "Enyim. caching. configuration. memcachedclientsection, enyim. Caching"   />  </  Sectiongroup  > 

2. Then add the following definitions on the <appsettings>

 <  Enyim.com  >    <  Memcached  >      <  Servers  >       <  Add   Address  = "127.0.0.1"   Port  = "11211"   />      </  Servers  >      <  Socketpool   Minpoolsize  = "10"   Maxpoolsize  = "100"          Connectiontimeout  = "00:00:10"   Deadtimeout  = "00:02:00"  />    </  Memcached  >  </  Enyim.com  >  <  Cacheprovider   Defaultprovider  = "Memcachedcacheprovider"  >    <  Providers  >      <  Add   Name  = "Memcachedcacheprovider"        Type = "Memcachedproviders. cache. memcachedcacheprovider, memcachedproviders"        Keysuffix  = "_ Myprojectname _"   Defaultexpiretime  = "2000"  />    </  Providers  >  </  Cacheprovider  > 

Start using memcached APIs

1. The memcachedproviders. cache name is empty.

 
UsingMemcachedproviders. cache;

2. Obtain the cache category

 
ObjectObjcache = distcache. Get (cachekey );

3. merge into the cache category

 
// Configure cache data (expiration time)Distcache. Add (cachekey, cachevalue );// Cache for 60 secondsDistcache. Add (cachekey, cachevalue, 60*1000 );// Cache to the end of todayDistcache. Add (cachekey, cachevalue, datetime. Today. adddays (1)-datetime. Now );

4. Remove the cache category

 
Distcache. Remove (cachekey );

5. Remove all cache targets

 
Distcache. removeall ();

--

Http://blog.miniasp.com/post/2010/01/27/Memcached-for-ASPNET-Quick-Start-Guide.aspx

Related Article

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.