Memcache Installation and testing tutorials under windows

Source: Internet
Author: User
Tags memcached memory usage overview example

Memcache installation under Windows
1, download memcache for Windows. Download Address: http://jehiah.cz/projects/memcached-win32, recommended download binaries version, decompression (in this case, extract to c:memcached).
2, in the command line state input: c:memcachedmemcached.exe-d install. This memcached has been installed as a Windows service
3, at the command line input: c:memcachedmemcached.exe-d start to start the memcached service. Of course, you can also choose to start in Windows services
You're right, that's it. Simple three-step memcache server End is ready

PHP Installation memcached module support
1, download the Php_memcache.dll module, you can find the corresponding version from Http://downloads.php.net/pierre/,
php5.3 Direct Download Http://shikii.net/blog/downloads/php_memcache-cvs-20090703-5.3-VC6-x86.zip

2, modify the php.ini, add the following content:

Extension=php_memcache.dll3, restart the Apache server, and then look at the phpinfo, if there is memcache, then the installation is successful!

To test memcached under Windows
The test code is as follows:

The code is as follows Copy Code

<?php
$mem = new Memcache;
$mem->connect ("127.0.0.1", 11211);
$mem->set (' key ', ' Hello memcached! ', 0, 60);
$val = $mem->get (' key ');
Echo $val;
?>

Example #1 memcache Extension Overview Example

In this example, a object is being saved in the cache and then retrieved. Object and other non-scalar types are serialized before saving, so it's impossible to store (i.e. connection IDE Ntifiers and others) in the cache.

  code is as follows copy code

<?php

$memcache = new Memcache;
$memcache->connect (' localhost ', 11211) or die ("could not Connect");

$version = $memcache->getversion ();
Echo "Server" version: ". $version." <br/>n ";

$tmp _object = new StdClass;
$tmp _object->str_attr = ' Test ';
$tmp _object->int_attr = 123;

$memcache->set (' key ', $tmp _object, False, or die ("Failed to save data at the server");
Echo Store data in the cache (data would expire in seconds) <br/>n ";

$get _result = $memcache->get (' key ');
Echo "Data from the Cache:<br/>n";

Var_dump ($get _result);

?


Example #2 Using memcache Session Handler

The code is as follows Copy Code

<?php

$session _save_path = "tcp://$host: $port? persistent=1&weight=2&timeout=2&retry_interval=10, tcp://$ Host: $port ";
Ini_set (' Session.save_handler ', ' memcache ');
Ini_set (' Session.save_path ', $session _save_path);

?>


-P Listening Port
-L connection IP address, default is native
-D start memcached service
-d Restart Restart memcached service
-D stop|shutdown shutdown running memcached Service
-d install install memcached service
-d uninstall Uninstall memcached Service
-u Run as (only when run as root)
-M max memory usage, Unit m B. The default 64MB
-M is running out of memory and not deleted
-C maximum number of simultaneous connections, default is 1024
-F block size growth factor, default is 1.25
-n Minimum allocation space, key+value+flags defaults to
-h Display Help

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.