====== Установка библиотеки php-memcache в CentOS ======
* http://code.google.com/p/memcached/wiki/NewConfiguringServer
* [[http://www.cyberciti.biz/faq/rhel-fedora-linux-install-memcached-caching-system-rpm/|Redhat / CentOS Install Memcached Caching System]]
* [[http://highload.com.ua/index.php/2010/05/07/memcache-vs-memached-сравниваем-клиенты-для-php|Сравнение memcache и memcached]]
===== Установка и настройка =====
==== Установка ====
Для установки понадобится репозиторий [[http://fedoraproject.org/wiki/EPEL|EPEL]] и репозиторий [[http://www.atomicorp.com/|Atomic]] или [[http://repoforge.org/|Repoforge]] (RPMForge)
# yum install memcached php-pecl-memcache
==== Настройка ====
Конфигурационный файл **/etc/sysconfig/memcached**
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="512"
OPTIONS="-l 127.0.0.1"
Добавляем в автозагрузку и запускаем демон
# chkconfig memcached on
# /etc/init.d/memcached start (или service memcached start)
===== Статистика использования =====
**Slabs**
# memcached-tool 127.0.0.1:11211
# memcached-tool 127.0.0.1:11211 display
# Item_Size Max_age Pages Count Full? Evicted Evict_Time OOM
2 104B 131s 1 2 no 0 0 0
4 176B 2s 1 1 no 0 0 0
7 352B 139s 1 3 no 0 0 0
10 696B 2s 1 1 no 0 0 0
12 1.1K 2s 1 1 no 0 0 0
14 1.7K 43s 1 1 no 0 0 0
15 2.1K 131s 1 1 no 0 0 0
20 6.4K 857s 1 1 no 0 0 0
Что такое **slab** и **slab-аллокатор** можно прочесть здесь:
* http://www.opennet.ru/base/dev/memcached_tips.txt.html
* http://work.tinou.com/2011/04/memcached-for-dummies.html
**Memory**
# memcached-tool 127.0.0.1:11211 stats
#127.0.0.1:11211 Field Value
accepting_conns 1
auth_cmds 0
auth_errors 0
bytes 11488
bytes_read 911390
bytes_written 12681000
cas_badval 0
cas_hits 0
cas_misses 0
cmd_flush 2
cmd_get 23585
cmd_set 17
cmd_touch 0
conn_yields 0
connection_structures 60
curr_connections 53
curr_items 11
decr_hits 0
decr_misses 0
delete_hits 0
delete_misses 0
evicted_unfetched 0
evictions 0
expired_unfetched 0
get_hits 23568
get_misses 17
hash_bytes 262144
hash_is_expanding 0
hash_power_level 16
incr_hits 0
incr_misses 0
libevent 1.4.13-stable
limit_maxbytes 67108864
listen_disabled_num 0
pid 483
pointer_size 32
reclaimed 1
reserved_fds 20
rusage_system 1.955702
rusage_user 0.518921
threads 4
time 1339581636
total_connections 3985
total_items 17
touch_hits 0
touch_misses 0
uptime 1469
version 1.4.13
====== php-сессии в memcached ======
* http://forum.ispsystem.com/ru/showthread.php?t=20105
* http://myforce.ru/tips-and-tricks/xranenie-sessij-php-v-memcached/
В **php.ini**:
session.save_path=tcp://127.0.0.1:11211
session.save_handler=memcache
session.name=SESSIONID
С ispmanager может быть ошибка
Fatal error: session_start(): Failed to initialize storage module: memcache (path: /home/user/data/mod-tmp) in ...
"Внутри VirtualHost в конфиге Apache прописан php_admin_value session.save_path и оттуда берется значение на которое ругается в ошибке."
===== Простое решение по борьбе со сбросом всего кеша в memcached =====
http://habrahabr.ru/post/154243/