Install and configure Memcached in php + memcachedWindows in windows. Method 1: extract the first package and put it on a disk, for example, in c: \ memcached. 2. enter 'C: \ memcached \ memcached.exe-install and configure php + memcached in windows on the terminal (that is, the cmd command interface ).
How to install and configure Memcached in Windows
1. extract the first package and put it under a certain disk, for example, in c: \ memcached.
2. enter 'C: \ memcached \ memcached.exe-d install' on the terminal (that is, the cmd command interface) for installation.
3. enter 'C: \ memcached \ memcached.exe-d start' to start. (Note: In the future, memcached will be automatically started every time it is started on windows. In this way, the server has been installed ).
4. download the php_memcache.dll file and put it in the ext Directory of the php folder.
5. add a reference extension line in php. ini. the code is as follows:
Extension = php_memcache.dll
6. add the following in the php. ini file:
[Memcache]memcache.allow_failover = 1memcache.max_failover_attempts=20memcache.chunk_size =8192memcache.default_port = 11211
? It is best to put it under "extension = php_memcache.dll" just now. (This is the default configuration)
7. restart Apache and check phpinfo. if memcache instructions are available, the installation is successful!
Write an example. php file (for more usage instructions, refer to the Memcache Functions instructions in the PHP Manual). the test code is as follows:
connect('localhost', 11211) or die ("Could not connect"); $version = $memcache->getVersion();echo "Server's version: ".$version."
\n"; $tmp_object = new stdClass;$tmp_object->str_attr = 'test';$tmp_object->int_attr = 123; $memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");echo "Store data in the cache (data will expire in 10 seconds)
\n"; $get_result = $memcache->get('key');echo "Data from the cache:
\n"; var_dump($get_result); ?>
? If the output is as follows, the test is successful:
Server's version: 1.4.5Store data in the cache (data will expire in 10 seconds)Data from the cache:object(stdClass)#3 (2) { ["str_attr"]=> string(4) "test" ["int_attr"]=> int(123) }
?
Basic Memcached parameter settings:
- -P listening port
- -L connected IP address. the default value is local
- -D start: start the memcached service.
- -D restart: restart the memcached service.
- -D stop | shutdown the running memcached service
- -D install the memcached service
- -D uninstall memcached service
- -U runs as the identity (only valid when running as root)
- -MB maximum memory usage, in MB. The default value is 64 MB.
- -An error is returned when M memory is used up, instead of deleting items.
- -C: maximum number of simultaneous connections. the default value is 1024.
- -F block size growth factor, default value: 1.25
- -N: Minimum allocation space. the default value of key + value + flags is 48.
- -H: Show Help <-->