Getting Started with memcached

Source: Internet
Author: User
Tags memcached

The resources used in this article are http://pan.baidu.com/s/1jHTRiU6

Use the documentation to be able to view (also included) in the Novice school

Http://www.runoob.com/memcached/window-install-memcached.html

Download the corresponding version of your system to unzip, perform the installation and start naming

Turn on the Telnet client service,

Dism-online-enable-feature-featurename:telnetclient (note capital Small)

View service Dism/online/get-featureinfo/featurename:telnetclient

Disable Dism/online/disable-feature/featurename:telnetclient

Telnet 127.0.0.1 11211 (default port 11211)

The Memcached set command is used to store value (data value) in the specified key (key).

If the set key already exists, the command can update the original data corresponding to the key, that is, the role of the update.

Set key flags Exptime bytes [noreply]

Value

The parameters are described as follows:

Key: Keys in the key-value structure to find the cached value.

Flags: You can include integer parameters for key-value pairs that the client uses to store additional information about key-value pairs.

Exptime: The length of time (in seconds, 0 for forever) that a key-value pair is saved in the cache

Bytes: The number of bytes stored in the cache

Noreply (optional): This parameter tells the server that it does not need to return data

Value: Stored values (always in the second row) (can be directly understood as value in the key-value structure)

Set Key1 0 3 //set key value is Key1, flags 0, expiration period 300 seconds, byte count is 3 (key-value-sensitive-size word)

ABC //Set key corresponding value (in the second row), set to display successfully STORED

Get Key1 //Take value

The Memcached add command is used to store value (data value) in the specified key (key).

If the add key already exists, the data will not be updated, and the previous value remains the same, and you will get the response not_stored.

The Memcached get command gets the value stored in the key (the data value) and returns NULL if the key does not exist.

Flush_all Clear memcached how to cache data in a

Graphical view Memcached (not required, can be skipped here)

How to install and configure the JDK, see http://www.cnblogs.com/likehc/p/6238224.html

Down to configure Tomcat, I'm using apache-tomcat-7.0.40-windows-x64 here, unzip to the C:\Tomcat directory,

Configure the environment variables for tomcat in path

Run Startup.bat in the Bin directory, and then open http://localhost:8080/, hmm, to see that Tomcat is working correctly.

Memadmin is a PHP file, default is not PHP-supported

Need to download PHP components, I am using the php-5.6.29-win32-vc11-x64

Create a PHP folder in the Tomcat root directory, unzip the php-5.6.29-win32-vc11-x64 to PHP directory,

Copy php.ini-development in PHP directory and name php.ini to modify php.ini content

    1. Remove Extension_dir = "ext" comment
    2. Cgi.force_redirect = 0

Modify Context.xml <Context> Add privileged= "true" property under the Tomcat directory, <context privileged="true">

Modify the Web. Xml under Tomcat's Webapps\root\web-inf directory

Add a PHP path to the <web-app> tab and the results are as follows

<?XML version= "1.0" encoding= "Iso-8859-1"?><Web-appxmlns= "Http://java.sun.com/xml/ns/javaee"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"version= "3.0"Metadata-complete= "true">  <servlet>     <Servlet-name>Php</Servlet-name>     <Servlet-class>Org.apache.catalina.servlets.CGIServlet</Servlet-class>     <Init-param>       <Param-name>Clientinputtimeout</Param-name>       <Param-value>200</Param-value>     </Init-param>     <Init-param>       <Param-name>Debug</Param-name>       <Param-value>0</Param-value>     </Init-param>     <Init-param>       <Param-name>Executable</Param-name>       <Param-value>C:\Tomcat\apache-tomcat-7.0.40\php\php-cgi.exe</Param-value>     </Init-param>     <Init-param>         <Param-name>Passshellenvironment</Param-name>     <Param-value>True</Param-value>     </Init-param>     <Init-param>       <Param-name>Cgipathprefix</Param-name>       <Param-value>Web-inf/memadmin</Param-value>     </Init-param>     <Load-on-startup>5</Load-on-startup>     </servlet>    <servlet-mapping>        <Servlet-name>Php</Servlet-name>        <Url-pattern>/memadmin/*</Url-pattern>     </servlet-mapping></Web-app>

Download Memadmin file http://www.junopen.com/memadmin/, extract to Tomcat's Webapps\root\web-inf directory, and rename to Memadmin

Open http://localhost:8080/memadmin/index.php uh, lack of extensions

PHP is missing Php_memcache.dll, php_memcache.dll and PHP version as far as possible or not installed memcache extension above ,

Download the Php_memcache.dll into the Php\ext directory, modify the Php\php.ini plus a extension=php_memcache.dll, then restart Tomcat. Then, it came in.

http://localhost:8080/memadmin/index.php

View the value of the newly set Key1

C # can be manipulated with the classes provided in memcacheddotnet_clientlib-1.1.5, requiring reference

Commons.dll,

ICSharpCode.SharpZipLib.dll,

Log4net.dll,

Memcached.ClientLibrary.dll

String[] Servers = {"127.0.0.1:11211"}; Sockiopool pool = sockiopool.getinstance ();p ool. Setservers (servers);p ool. Initconnections = 3;pool. Minconnections = 3;pool. MaxConnections = 5;pool. Socketconnecttimeout = 1000;pool. Sockettimeout = 3000;pool. Maintenancesleep = 30;pool. Failover = True;pool. Nagle = False;pool. Initialize (); Memcachedclient memclient = new Memcachedclient () Memclient.enablecompression = False;memclient.set ("Key1", "111"); Memclient.set ("Key2", "222"); Memclient.set ("Key3", "333"); var has = memclient.keyexists ("Key2");   Whether the deposit key Console.WriteLine (has), Var key2= memclient.get ("Key2"); Get the corresponding value Console.WriteLine (Key2); Memclient.delete ("Key2"); Delete Console.readkey ();

  

Getting Started with memcached

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.