Get started with memcached and memcached

Source: Internet
Author: User

Get started with memcached and memcached

Resource http://pan.baidu.com/s/1jHTRiU6 used in this article

 

You can view the usage documents at cainiao School (also included)

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

Download and decompress the corresponding version of your system, and name the installation and startup.

 

 

 

Enable the telnet client service,

Dism-online-enable-feature-featurename: TelnetClient (small in upper case)

 

 

 

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 values in the specified key.

 

 

If the set key already exists, this command can update the original data corresponding to the key.

Set key flags exptime bytes [noreply]

Value

Parameters are described as follows:

Key: the key in the key-value structure, used to find the cache value.

Flags: it can include an integer parameter of a key-value pair. The client uses it to store additional information about the key-value pair.

Exptime: the length of time for saving the key-value pair in the cache (in seconds, 0 indicates permanent)

Bytes: the number of bytes stored in the cache.

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

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

 

Set key1 0 300 3 // set key value: key1, flags: 0, expiration period: 300 seconds, number of bytes: 3 (key value differentiation word)

ABC // set the value corresponding to the key (in the second row). The value is displayed successfully.STORED

 

Get Key1 // Value

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

If the add key already exists, the data will not be updated, the previous values will remain the same, and you will get the response NOT_STORED.

 

The Memcached get command gets the value (data value) stored in the key. If the key does not exist, null is returned.

 

Flush_allClearMemcachedMethod of cached data

 

View Memcached in graphical mode (skip this step if you do not need it)

 

How to install and configure jdk, please refer to the http://www.cnblogs.com/likehc/p/6238224.html

 

 

To configure Tomcat, I use a apache-tomcat-7.0.40-windows-x64 here, unzip to the C: \ Tomcat directory,

 

Configure tomcat environment variables in path

 

 

 

 

Run startup. bat in the bin directory and enable http: // localhost: 8080.

 

 

 

Memadmin is a php file and does not support php by default.

 

 

I need to download the php component.Php-5.6.29-Win32-VC11-x64

 

Create a php folder in the tomcat root directory and decompress it.Php-5.6.29-Win32-VC11-x64To the php Directory,

Copy php. ini-development in the php Directory and name it php. ini. Modify the php. ini content.

 

Modify the context. xml <Context> In the tomcat directory and add the privileged = "true" attribute. <Context privileged ="True">

Modify web. xml under tomcat's webapps \ ROOT \ WEB-INF directory

Add the php path to the <web-app> label. The final result is as follows:

 

<?xml version="1.0" encoding="ISO-8859-1"?><web-app xmlns="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 the MemAdmin file http://www.junopen.com/memadmin/, decompress it to the Tomcat web‑root‑web-inf directory, and rename it to memadmin.

 

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

 

 

Php lacks php_memcache.dll,Php_memcache.dllAnd phpTry your bestOtherwise, the above Memcache is not installed.Extension,

Download php_memcache.dll and put it into the php \ ext directory. Modify php \ php. ini and add extension = php_memcache.dll. Then restart tomcat. Then, the system comes in.

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

 

 

 

View the value of the newly set key1

 

 

 

C # can be operated with the class provided in the memcacheddotnet_clientlib-1.1.5, need to reference

Commons. dll,

ICSharpCode. SharpZipLib. dll,

Log4net. dll,

Memcached. ClientLibrary. dll

 

 

 

String [] servers = {"127.0.0.1: 11211"}; SockIOPool pool = SockIOPool. getInstance (); pool. setServers (servers); pool. 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 to save the key Console. writeLine (has); var key2 = memClient. get ("key2"); // obtain the corresponding value Console. writeLine (key2); memClient. delete ("key2"); // Delete the Console. readKey ();

  

 

 

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.