Php memcache (Classic php cache)

Source: Internet
Author: User
Tags php memcached

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.