The Memcache function library is in PECL (PHPExtensionCommunityLibrary). It is mainly used to set up a temporary storage area for large-capacity memory data. its function is obvious in distributed mode, otherwise it is not recommended to use it. MemcacheEMC error reported when installing and running on ubuntu
The Memcache function Library is used in the PECL (PHP Extension Community Library) to build a temporary storage area for large-capacity memory data. Its role is evident in distributed systems, otherwise, it is not recommended. When installing and running ubuntu, 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.
Log out of the ";" in/etc/php5/conf. d/memcached. ini, restart apache, and call phpinfo () to display memcached information.
$ Memcache = new Memcache; $ Memcache-> connect ('localhost', 11211) or die ("cocould not connect "); $ Version = $ memcache-> getVersion (); Echo "Server's version:". $ version. "\ n "; ?> |
-
- $ 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
- *)
- */
- ?>
|
01. 02. $ memcache = new Memcache; 03. $ memcache-> connect ('localhost', 11211) or die ("cocould not connect "); 04. $ memcache-> set ('name', 'Leo ', 0, 30 ); 05. if (! $ Memcache-> add ('name', 'Susan ', 0, 30 )) 06 .{ 07. echo 'Susan is exist '; 08 .}; 09. $ memcache-> replace ('name', 'power', 0,300 ); 10. echo $ memcache-> get ('name '); 11. $ memcache-> delete ('name', 5 ); 12.?> |
01. 02. function _ callback_memcache_failure ($ host, $ port ){ 03. print "memcache '$ host: $ port 'failed "; 04 .} 05. $ memcache = new Memcache; 06. $ memcache-> addServer ('192. 168.1.116', 192 ); 07. $ memcache-> setServerParams ('192. 168.1.116', 192, 1, 15, true, 08. 09. '_ callback_memcache_failure '); 10. echo $ memcache-> getServerStatus ('192. 168.1.116', 192 ); 11.?> |
01. 02. $ memcache = new Memcache; 03. $ memcache-> connect ('localhost', 11211 ); 04. $ memcache-> set ('test _ item', 8 ); 05. $ memcache-> increment ('test _ item', 4 ); 06. echo $ memcache-> decrement ('test _ item', 7 ); 07. // Display 5 08.?> |
/Usr/local/bin/memcached-d-m 10-u root-l 127.0.0.1-p 11211-c 256-P /Tmp/memcached. pid |