Using this tutorial you will know, How to use memcached with php. We given code for using memcache with php. we shown you to configure memcache with php.
How to use memcached with php
If you try to install memcached with Linux server then use following commands
# yum install libevent
# yum install libmemcached libmemcached-devel
# yum install memcached
For Starting the memcached server
# memcached -d -m 512 -l 127.0.0.1 -p 11211 -u nobody
11211 port is default port for memcached server.
For using the memecached with php client you need to install following package
# pecl install memcache
After installing all packages restart the apache server.
# /etc/sbin/service httpd restart
<!--?php /* OO API */ $memcache_obj = new Memcache; $memcache_obj--->connect('memcache_host', 11211); $memcache_obj->set('any_key', 'some value', MEMCACHE_COMPRESSED, 50); echo $memcache_obj->get('any_key'); ?>
Important Note: Memcached key has limitations of 250 charactors, So key value should be with in 250 charactors.