mencached Use of small notes

Source: Internet
Author: User

This article simply records how Memcached is installed and configured under the Windows platform, and Memcached is a high-performance distributed memory object caching system for dynamic Web applications to mitigate database load.

1. Download memcached for Windows

Click to download (version 1.4.5)

Description: Win64bit 1.4.4 This version of the memcached have said that the cache expiration time and large concurrency when caching will fail, so it is recommended to install 1.4.5 version, the version will be more stable

2, installation memcached

Put the downloaded memcached file on the D drive, my path is as follows:

D:\Cache\memcached\64bit

  

2.1. Command line Installation

My system is 64bit, so I installed a 64-bit Memcached-1.4.5

  installation command:

1. Run as Administrator cmd.exe

2. Go to the Memcached folder
C:\users\chenlong1>d:

D:\>CD Cache\memcached\64bit

3. Installation
d:\cache\memcached\64bit>memcached-1.4.5.exe-d Install

4. Start
d:\cache\memcached\64bit>memcached-1.4.5.exe-d start

 

memcached installation ends, memcached is running with Windows service, let's see if our memcached is installed successfully.

CMD command services.msc Open the Windows service and locate the Memcached service, stating that the installation was successful

Installation parameter Description:

Input command: D:\cache\memcached\64bit>memcached-1.4.5.exe-h can view the installation parameters of memcached

The specific meanings of the parameters correspond to the following:

-P Listening Port
-L connected IP address, default is native
-D Start memcached service
-D Restart Restart memcached service
-D Stop|shutdown Close the running memcached service
-D Install memcached service
-d Uninstall Uninstall memcached service
-U Run as (only valid when running as root)
-m maximum memory usage, in megabytes. Default 64MB
-M running out of memory and returning an error instead of deleting an item
-c Maximum number of simultaneous connections, default is 1024
-F Block size growth factor, default is 1.25
-N Minimum allocated space, key+value+flags default is 48
-H Display Help

2.2 Bat batch file installation

1. Install the start memcached Batch command as follows:

echo Start install MEMCACHEDCD D:\Cache\memcachedmemcached-1.4. 5. exe-d installecho start memcached servicememcached-1.4. 5. exe-d startecho endpause

2. The batch command to stop and unload memcached is as follows:

echo Start Uninstall MEMCACHEDCD D:\Cache\memcachedmemcached-1.4. 5. exe-d stopmemcached-1.4. 5. exe-d uninstall Echo endpause

Run a batch file as an administrator to install or uninstall the memcached service

3. Using memcached in. NET programs

Since the enyimmemcached.2.13 operation memcached Cache is used in the current project, I also introduce the simple use of enyimmemcached

Installing enyimmemcached.2.13 with NuGet

1. Web. config configuration file

<configuration> <configSections> <sectiongroup name="enyim.com"> <section name="memcached"Type="enyim.caching.configuration.memcachedclientsection,enyim.caching"/> </sectionGroup> <section name="memcached"Type="Enyim.Caching.Configuration.MemcachedClientSection, enyim.caching"/> </configSections> <enyim.com> <memcached> <servers> <!--put your own SE RVer (s) here--> <add address="127.0.0.1"port="11211"/> </servers> <socketpool minpoolsize="Ten"Maxpoolsize=" -"connectiontimeout="00:00:10"deadtimeout="00:02:00"/> </memcached> </enyim.com> <memcached keytransformer="enyim.caching.tigerhashtransformer,enyim.caching"> <servers> <add address="127.0.0.1"port="11211"/> </servers> <socketpool minpoolsize="2"Maxpoolsize=" -"connectiontimeout="00:00:10"deadtimeout="00:02:00"/> </memcached></configuration>

2, Memcachedhelper

usingenyim.caching;usingEnyim.Caching.Configuration;usingEnyim.Caching.Memcached;usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Net;usingSystem.Net.Sockets;usingSystem.Text;usingSystem.Threading.Tasks;namespaceclasslibrary1{ Public Sealed classMemcachedhelper {Private Staticmemcachedclient memclient; Static ReadOnly Objectpadlock =New Object(); //thread-Safe single-case mode         Public Staticmemcachedclient getinstance () {if(Memclient = =NULL)            {                Lock(padlock) {if(Memclient = =NULL) {memclientinit (); }                }            }            returnmemclient; }        //Initializing the cache        Static voidMemclientinit () {Try{memclient=NewMemcachedclient ("enyim.com/memcached"); }            Catch(Exception ex) {Throwex; }        }        //constructor Function        StaticMemcachedhelper () {getinstance (); }         Public Static voidStore (stringKey,ObjectValue, DateTime expiredat)        {Memclient.store (Storemode.set, Key, Value, Expiredat); }         Public StaticT get<t> (stringKey) {            returnMemclient.get<t>(Key); }         Public Static voidRemove (stringKey)        {Memclient.remove (Key); }    }}

3. Call Test

This article refers to:

Http://www.cnblogs.com/lucky_hu/p/4676734.html

  

  

mencached Use of small notes

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.