Php memory cache memcached instance. Memcached is a high-performance, distributed memory object cache system that reduces database loads in Dynamic Applications and improves access speeds. Developed by DangaInteractive, Memcached is a high-performance, distributed memory object cache system that reduces database load and improves access speed in dynamic applications. Developed by Danga Interactive, Memcached improves the access speed of LiveJournal.com. The number of dynamic page views per second on the LJ is several thousand, and the number of users is 7 million. Memcached greatly reduces the database load and makes it easier to allocate resources for faster access.
Memory cache memcached instance in php Tutorial
Install memcache in windows:
1. download the stable version of memcache for windows and decompress it to a disk, for example, in c: memcached
2. enter 'C: memcachedmemcached.exe-d install in the terminal (that is, the cmd command interface)
'Installation
3. enter 'C: memcachedmemcached.exe-d start' to start. Note: Later
Memcached is used as a windows service and automatically starts every time it is started. In this way, the server has been installed
Complete.
4. download http://cmy2009.ihost.tw/download, (php_memcache address) please find the corresponding
Php files
5. add a line 'extension = php_memcache.dll 'to c: winntphp. ini'
6. restart apache and check phpinfo. if memcache exists, the installation is successful!
Basic settings of memcached:
-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
Test the memcache environment:
Run the following php file. if there is output, the environment is successfully set up. Start to appreciate the charm of memcache
!
$ Memcache = memcache_connect ('localhost', 11211 );
If ($ memcache ){
$ Memcache-> set ("str_key", "string to store in memcached ");
$ Memcache-> set ("num_key", 123 );
$ Object = new stdclass;
$ Object-> attribute = 'test ';
$ Memcache-> set ("obj_key", $ object );
$ Array = array ('assoc '=> 123,345,567 );
$ Memcache-> set ("arr_key", $ array );
Var_dump ($ memcache-> get ('Str _ key '));
Var_dump ($ memcache-> get ('Num _ key '));
Var_dump ($ memcache-> get ('obj _ key '));
}
Else {
Echo "connection to memcached failed ";
}
?>
Memcached is a high-performance, distributed memory object cache system that reduces the database tutorial load in Dynamic Applications and improves access speed.
Developed by danga interactive, memcached improves the access speed of livejournal.com. The number of dynamic page views per second on the lj is several thousand, and the number of users is 7 million. Memcached greatly reduces the database load and makes it easier to allocate resources for faster access.
Why not use a database to do this?
What kind of database (ms-SQL, oracle, S, mysql tutorial-innodb, etc ..) are not considered for the moment ..), implementing acid, atomicity, consistency, isolation, and durability requires a lot of overhead. especially when using hard disks, this means that the query may be blocked. When a database that does not contain transactions (such as mysql-myisam) is used, the preceding overhead does not exist, but the read thread may be blocked by the write thread.
Memcached never blocks and is very fast.
Bytes. Memcached was developed by Danga Interactive to improve...