Installation of memcache


memcached:

tar xf tar xf libevent-2.0.21-stable.tar.gz

cd libevent-2.0.21-stable

./configure --prifix=/usr

make && make install

tar xf memcached-1.4.15.tar.gz

cd memcached-1.4.15

./configure --with-libevent=/usr/

make && make install


start up:

/usr/local/bin/memcached -d -m 512 -u root -p 11211 -c 1000 -M -f 1.1 -P /tmp/memcached.pid

Introduction to the use of memcached parameters (Win7 users should start the command window as an administrator!)

-p listen port

-l The IP address of the connection, the default is the local machine

-d start start the memcached service

-d restart restart memcached service

-d stop|shutdown Shut down the running memcached service

-d install install memcached service

-d uninstall uninstalls the memcached service

-u run as (only valid when running as root)

-m Maximum memory usage, in MB. Default 64MB

-M returns an error when memory is exhausted instead of deleting items

-c The maximum number of simultaneous connections, the default is 1024

-f block size growth factor, default is 1.25

-n Minimum allocation space, key+value+flags defaults to 48

-P specifies the location and name of the PID file

-h show help


There are two ways to clear the memcache cache

1. Log in to memcached

telent localhost 11211

After entering, execute flush_all

2.echo "flush_all"|nc localhost 11211


Check cache status

telnet localhost 11211
Trying ::1...
Connected to localhost.
Escape character is '^]'.
stats

STAT cmd_get 0 #Total number of times to get data (equal to get_hits + get_misses)

STAT cmd_set 0 #Total number of times to set data

STAT get_hits 0 #How many times the data was hit, that is, the number of times the data was successfully obtained from the Memcached cache

STAT get_misses 0 #Number of missed hits

STAT limit_maxbytes 536870912 #Total storage size, default 64M

STAT bytes 0 #The size of the currently used storage

END

The hit rate of the data = the total number of times the data was obtained / the number of times the data was hit

===============================================================================

php's memcache module

 

wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz

wget http://pecl.php.net/get/memcached-3.0.3.tgz

wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz

wget http://www.memcached.org/files/memcached-1.5.2.tar.gz

tar xf libmemcached-1.0.18.tar.gz

cd libmemcached-1.0.18

./configure --prefix=/usr/local/libmemcached --with-memcached

make && make install

cd /root

tar xf memcached-3.0.3.tgz

cd memcached-3.0.3

/usr/local/php/bin/phpize

./configure --enable-memcached --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached/ --disable-memcached-sasl

make && make install

cat /usr/local/php/lib/php.ini

[Memcached]
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/"
extension = memcached.so

Just put it at the end

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324648602&siteId=291194637