Memcached installation and simple and practical use

Source: Internet
Author: User
Tags memcached yii

First, Introduction 1.memcache and memcached of the difference and contact:   Memcache is the extension of PHP, memcached is the client, Complex said: Memcache module provides a convenient process-oriented and object-oriented interface memcached, memcached is to reduce dynamic Web applications A resident process cache product that results from loading data from a database. Second, installation Windows 64-bit Memcached:http://www.urielkatz.com/projects/memcached-win64/memcached-win64.zip 1. Installing Memacached.exe Create a new memcached folder under C, unzip the download memcached to this folder Enter CMD in the beginning, locate the Cmd.exe program, right-click on it, select "Run as Administrator" ③ input: cmd c:/memcached④ input: memcached.exe-d Install//installation Memcached⑤ input: MEMCAC hed.exe-d Start//Startup memcached 2. Installing Php_memcached.dll① to the back page download Memcache.dll http://pecl.php.net/package/memcache/3.0.8/windows//To download the same DLL file as your own software integration pack version, such as: ① your xampp is 32 bits, you'll need to download x86 's ②phpinfo () to show thread Safety (thread safe): enabled you need to download ts otherwise, download Nts② copy the downloaded DLL file to: /php/ext directory ③ added in php.in Extension=php_memcache.dll  ④ Restart Apace 3. Using Memcahe$mem = new Memcache;
$mem->connect ("127.0.0.1", 11211);
$mem->set (' key ', ' Hello memcached! ', 0, 60);
$val = $mem->get (' key ');
Echo $val; Output: Hello memcached!, the installation is successful, you can use Memcached//TP5 in the memcachedconfig.php configuration file to modify the cache type to Memcachecache::set (' name ', $ VALUE,3600); Cache::get (' name ', ');//The following is the usage of memcached in yii2 $memcached = Yii:: $app->cache->add (' Sex ', ' nan '); $memcachedGet = Yii:: $app->cache->get (' sex '); Echo $memcachedGet; 4. Common settings:

-P <num> Monitored ports

-L <ip_addr> 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 <username> Run as <username> (only valid when run as root)

-M <num> maximum memory usage, in megabytes. Default 64MB

-M running out of memory and returning an error instead of deleting an item

-C <num> Maximum number of simultaneous connections, default is 1024

-F <factor> block size growth factor, default is 1.25

-N <bytes> Minimum allocated space, key+value+flags default is 48

-H Display Help

5. Note the event

If-M is specified, the number after the cache size is-m, in units such as:

C:/memcached/memcached.exe–l 127.0.0.1–m 200-d Start

After installing according to the above installation steps, using Memcached–m 200来 to adjust the maximum memory consumption will find no effect, always the default 64MB of memory, the reason may be that the registry does not write information, can be modified.

1, memcached–d shutdown first shut down the memcached service.

2. Enter the registry and locate Hkey_local_machine/system/currentcontrolset/services/memcached Server, where there is a ImagePath entry with a value of "c:/ Memcached/memcached.exe "-D runservice, followed by the-L 127.0.0.1-M 200-c 1024.

3, memcached–d start memcached service, this will memcached the maximum memory modification in order to 200MB.

Memcached installation and simple and practical use

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.