memcached命令率=git_hits/curr_items
查看memcached狀態
memcached-tool 服務端IP:服務端端口 stats
echo stats |nc 服務端IP 服務端端口
memstat --servers=服務端IP:服務端端口
創建數據和查看數據
set key2 0 30 2
說明;30是過期時間(如果設置成0,代表永不過期);2是字符長度;0是flags的標記(一般是開發的定義來創建)
set在沒有對應的key時候就增加,有的就覆蓋
add是增加key,存在的是失敗
導出和導入(因爲memcached是把數據緩存在內存中,在重啓服務或者是重啓機器前做備份)
導出
memcached-tool 服務端IP:服務端端口 dump > xxx
導入
nc 服務端IP 服務端端口 < xxx
php的memcache模塊
wget http://www.apelearn.com/bbs/data/attachment/forum/memcache-2.2.3.tgz
php7的memcache模塊
wget https://github.com/websupport-sk/pecl-memcache/archive/php7.zip
unzip pecl-memcache-php7.zip
cd pecl-memcache-php7
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcache
make && make install