Windows installation configuration memcache and memcached

Source: Internet
Author: User
Tags crc32 memcached
1: Download

Php_memcache-2.2.6-5.3-vc9-x86.zip

Memcached-1.2.6-win32-bin.zip


2: Decompression Configuration

A.memcache

After decompression to get php_memcache.dll and compile good memcached.exe

Open your php/ext and copy php_memcache.dll, like my copy in F:/php/php5/ext.

Open php.ini, Find extension, add

Extension=php_memcache.dll

After saving, copy one to the Windows directory. C:/windows restart Apache.


B.memcached

Copy Memcached.exe to any directory, I put it in the F:/php/mem.

CMD into the F:/php/mem run (if you want to uninstall, change the install to uninstall)

memcached.exe-d Install

Open Service Command Line input

net start "memcached Server"

Open Task Manager to see the memcached.exe process.

Start command Line Input

f:/php/mem/memcached.exe-d start

The above can add parameters., specify memory partition-M, IP monitor-l 192.168.1.*, port number-p 11211, etc.

You can refer to Memcached's PHP manual. The address is here. The http://php.net/manual/en/book.memcached.php page has a Chinese version.

Go to telnet localhost 11211

Enter. Enter version view, enter stats View status


3: Browser open phpinfo.php

can find Memcache. memcache

memcache Support enabled
Active Persistent connections 0
Version 2.2.6
Revision $Revision: 296899 $

Local
DirectiveValue Master Value
Memcache.allow_failover 1 1
Memcache.chunk_size 8192 8192
Memcache.default_port 11211 11211
Memcache.default_timeout_ms 1000 1000
Memcache.hash_function Crc32 Crc32
Memcache.hash_strategy Standard Standard
Memcache.max_failover_attempts 20 20

Create a new PHP file, such as my testmemcache.php

<?php
	$mem =new Memcache;
	$mem->connect ("localhost", 11211);	Pconnect Long link
	//$mem->addserver ("www.test.com", 11221);	Add multiple servers
	//$mem->addserver ("192.168.1.9", 11211);

	$mem->add ("MyStr", "This is a memcache test!", memcache_compressed,3600);
	$str = $mem->get ("mystr");
	echo "string:". $str. " <br/> ";

	$mem->add ("Myarr", Array ("AAA", "BBB", "CCC", "ddd"));
	Print_r ($mem->get ("Myarr"));

	echo ' <br/> ';
	Class TESTC
		{
			var $name = "Tom";
			var $age =5;
			var $money =100;	
		}
	$mem->add ("MyObj", new TESTC);

	Var_dump ($mem->get ("MyObj"));
	echo ' <br/> ';
	echo $mem->getversion (). <br/> ";
	Echo ' <pre> ';
	Print_r ($mem->getstats ());
	Echo ' </pre> ';
	
	$mem->close ();
?

Browser Open testmemcache.php get

String:this is a memcache test!
Array ([0] => AAA [1] => BBB [2] => CCC [3] => DDD) 
object (TESTC) [2] public
  ' name ' => string ' Tom ' (length=3) public
  ' age ' => int 5 '
  => int

1.2.6
Array
(
    [PID] => 868< C9/>[uptime] => 3335
    [TIME] => 1316167200
    [version] => 1.2.6
    [pointer_size] =>
    [ Curr_items] => 3
    [Total_items] => 6
    [bytes] =>
    [curr_connections] => 3
    [Total_ Connections] =>
    [connection_structures] => 4
    [cmd_get] => [cmd_set
    ] => [
    get_ hits] =>
    [get_misses] => 1
    [evictions] => 0
    [bytes_read] => 2251
    [Bytes_written] = > 4515
    [limit_maxbytes] => 67108864
    [Threads] => 1
)

In the Telnet interface just in turn, enter get mystr, get Myarr, get myobj



4: No more

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.