python Memcached

Memcached

installation

wget http://memcached.org/latest
tar -zxvf memcached-1.x.x.tar.gz
cd memcached-1.x.x
./configure && make && make test && sudo make install
 
PS:依赖libevent
       yum install libevent-devel
       apt-get install libevent-dev

start up

. 1 the memcached -d -m 10     -u the root -l 10.211 . 55.4 -p 12000 -C 256 -P / tmp / memcached.pid
 2   
. 3  Parameter Description:
 . 4      - D a daemon is started
 . 5      - m is assigned to use Memcache the amount of memory, the unit is MB
 6      - U user is running Memcache
 7      - L IP address of the server is listening
 8      - the p-set Memcache is listening port, preferably more than 1024 ports
 9      - c option is the biggest run concurrent number of connections, default is 1024, in accordance with the load of your server to set the
 10      -P pid file is set to save the Memcache

connection

Installation api

 

. 1 Python Memcached operation using Python - the memcached module 
3 download and install: HTTPS: // pypi.python.org/pypi/python-memcached

access

memcache Import 
 # Debug = True said in a runtime error occurs, the real error message on the line after removing the parameters. 
MC = memcache.Client ([ ' 10.211.55.4:12000 ' ], Debug = True) 
mc.set ( " foo " , " bar " ) 
RET = mc.get ( ' foo ' ) 
Print RET

operating

 

Guess you like

Origin www.cnblogs.com/huay/p/11596807.html