Memcached is a high-performance, distributed memory object caching system for reducing database load and increasing access speed in dynamic applications. Memcached is developed by Danga Interactive to increase the speed of livejournal.com access. LJ Dynamic page visits thousands of times per second, user 7 million. Memcached significantly reduces database load, better allocation of resources, faster access.
PHP tutorials in memory cache memcached instances
Memcache installation under Windows:
1. Download Memcache's Windows stable version and unzip it under a disk, for example, in c:memcached
2. Enter ' c:memcachedmemcached.exe-d install ' in terminal (also cmd command interface)
' Installation
3. Re-enter: ' c:memcachedmemcached.exe-d start ' starts. Note: Later
Memcached will start automatically every time a service is powered on for Windows. So the server side is already installed
Finished.
4. Download Http://cmy2009.ihost.tw/download, (Php_memcache address) please find the corresponding
PHP Versions of files
5. Add a line of ' Extension=php_memcache.dll ' to C:winntphp.ini
6. Restart Apache, then check the phpinfo, if there is memcache, then the installation is successful!
Basic Settings for memcached:
-P Listening Port
-L 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 Run as (only valid when running as root)
-m maximum memory usage, in megabytes. Default 64MB
-M memory is exhausted when an error is returned instead of deleting an item
-c Maximum number of simultaneous connections, default is 1024
-F Block size growth factor, default is 1.25
-N Minimum allocated space, key+value+flags default is 48
-H Display Help
Memcache Environmental Testing:
Running the following PHP file, if there is output, indicates that the environment was built successfully. Begin 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 caching system that reduces database tutorial load and increases access speed in dynamic applications.
Memcached is developed by Danga Interactive to increase the speed of livejournal.com access. LJ Dynamic page visits thousands of times per second, user 7 million. Memcached significantly reduces database load, better allocation of resources, faster access.
Why not use a database to do this?
For the moment, do not consider what database (Ms-sql, Oracle, Postgres, MySQL tutorial-innodb, etc), implement transactions (acid,atomicity, consistency, isolation, and Durability) requires a lot of overhead, especially when used on a hard disk, which means that queries can be blocked. When using a database that does not contain transactions (for example, Mysql-myisam), the overhead does not exist, but the read thread may be blocked by the write thread.
Memcached never block, very fast.
http://www.bkjia.com/PHPjc/630846.html www.bkjia.com true http://www.bkjia.com/PHPjc/630846.html techarticle memcached is a high-performance, distributed memory object caching system for reducing database load and increasing access speed in dynamic applications. Memcached developed by Danga Interactive for the promotion of ...