ArticleDirectory
I have heard that memcached is a good distributed memory cache system. I have done some homework and want to use this memcache in practice. A good cache system can greatly improve the performance of Web applications. after doing some homework, I made the following summary:
- Memcache can be installed on the same server as Web server.
- Memcache can enable N processes on N ports. If it is on the same machine as the Web server, the network overhead can be reduced.
- Simple configuration: Start a process without the configuration file
I am more concerned about how to deploy memcache distributed applications. with this problem, I did some further work on various search engines. the initial solution was to start n memcache processes on different ports of different servers.
The Perl API can be used to easily link Multiple memcache files at a time. The storage and read mechanism is unknown. soon I found a memcachedclient class in PHP, which is basically the re-implementation of APIs in Perl. it uses fscokopen or socket series functions to directly read and retrieve memcache. This indicates that you do not even need to install the memcache extenstion in PHP as long as you know the network protocol of memcache. after reading the implementation of this class, we basically figured out that its distributed application basically stores different keys in different memcache daemon without retaining multiple copies, there is no problem of multi-memcache synchronization.
After a while, I found that the memcache: addserver () method was found in the latest PHP manual, which was generated for distributed applications. With this support, PHPCodeIt is simpler:
<? PHP
$ Memcache_obj = new memcache;
$ Memcache_obj-> addserver ('memcache _ host', 11211 );
$ Memcache_obj-> addserver ('failed _ host', 11211 );
$ Stats = $ memcache_obj-> getextendedstats ();
Print_r ($ stats );
?>
It seems that the PHP manual should keep pace with the times. It is best to use the English version directly, otherwise it will not take so many detours :)
Official site
Http://www.danga.com/memcached/