The Memcache function Library is used in the PECL (PHP Extension Community Library) to build large-capacity memory data.
The temporary storage area plays an obvious role in the distributed mode. Otherwise, it is not recommended. I installed it on ubuntu.
When running, an error is reported:
/Usr/local/memcached/bin/memcached: error while loading shared libraries: libevent-1.4.so.2:
Cannot open shared object file: No such file or directory
Follow the methods in libeven, memcached, and libmemcache installation to use:
Sudo ln-s/usr/local/lib/libevent-1.4.so.2/usr/lib/libevent-1.4.so.2
This BUG can be fixed.
Run the new php memcached module to log out ";" in/etc/php5/conf. d/memcached. ini and restart apache.
, Call phpinfo () to display memcached information.
Run:
<? Php
$ Memcache = new Memcache;
$ Memcache-> connect (localhost, 11211) or die ("cocould not connect ");
$ Version = $ memcache-> getVersion ();
Echo "Servers version:". $ version ."
";
?>
<? Php
$ Memcache = new Memcache;
$ Memcache-> connect (localhost, 11211) or die ("cocould not connect ");
Print_r ($ memcache-> getStats ());
/**
* Array
*(
* [Pid] = & gt; 8052
* [Uptime] = & gt; 9205
* [Time] = & gt; 1205898428
* [Version] => 1.2.5
* [Pointer_size] => 32
* [Rusage_user] = & gt; 0.008000
* [Rusage_system] = & gt; 0.000000
* [Curr_items] => 1
* [Total_items] => 17
* [Bytes] => 57
* [Curr_connections] => 2
* [Total_connections] => 15
* [Connection_structures] => 3
* [Cmd_get] => 9
* [Cmd_set] => 23
* [Get_hits] => 5
* [Get_misses] => 4
* [Evictions] => 0
* [Bytes_read] = & gt; 671
* [Bytes_written] = & gt; 850
* [Limit_maxbytes] = & gt; 10485760
* [Threads] => 1
*)
*/
?>
<? Php
$ Memcache = new Memcache;
$ Memcache-> connect (localhost, 11211) or die ("cocould not connect ");
$ Memcache-> set (name, leo, 0, 30 );
If (! $ Memcache-> add (name, susan, 0, 30 ))
{
Echo susan is exist;
};
$ Memcache-> replace (name, lion, 0,300 );
Echo $ memcache-> get