PHP MEMCACHE detailed (classic PHP cache) _php Tutorial

Source: Internet
Author: User
Memcache function library is in pecl (PHP Extension Community Library), the main role is to build large-capacity memory data

Temporary storage area, in the distribution of the effect is very obvious, otherwise it is not recommended. I installed on Ubuntu

When you finish running the error:
/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

According to: "Libeven, memcached, Libmemcache Installation" method, using:

sudo ln-s/usr/local/lib/libevent-1.4.so.2/usr/lib/libevent-1.4.so.2
Can fix this bug

With the new memcached module that installs PHP, unregister the ";" in/etc/php5/conf.d/memcached.ini and restart Apache

, call Phpinfo () to appear memcached information

Perform:
$memcache = new Memcache ;
$memcache - Connect ( localhost , 11211 ) or Die ( "Could not Connect" );
$version = $memcache - getversion ();
Echo "Servers version:" . $version . "
" ;
?>
$memcache = new Memcache ;
$memcache - Connect ( localhost , 11211 ) or Die ( "Could not Connect" );
Print_r ( $memcache - GetStats ());
/**
* Array
* (
* [PID] = 8052
* [Uptime] = 9205
* [TIME] = 1205898428
* [Version] = 1.2.5
* [Pointer_size] = 32
* [Rusage_user] = 0.008000
* [Rusage_system] = 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] = 671
* [Bytes_written] = 850
* [Limit_maxbytes] = 10485760
* [Threads] = 1
* )
*/
?>
$memcache = new Memcache ;
$memcache - Connect ( localhost , 11211 ) or Die ( "Could not Connect" );
$memcache - Set ( name , Leo , 0 , - );
if (! $memcache - Add ( name , Susan , 0 , - ))
{
Echo Susan is exist ;
};
$memcache - Replace ( name , Lion , 0 , - );
Echo $memcache - get

http://www.bkjia.com/phpjc/ 486423.html www.bkjia.com true http://www.bkjia.com/phpjc/486423.html techarticle Memcache function library is in PECL (Phpextensioncommunitylibrary), the main role is to build a large amount of memory data in the temporary storage area, in the distribution of the role of the very obvious, ...

  • 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.