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.

You might also like

Memcached Server with Rails
How we configure memcached on fedora with machine restart
How to install php – memcached server on centos5 or any linux OS
how to install vlc player on fedora 9
how to install php-pear on centos or redhat

One Response to “How to use memcached with php”

  1. SEOMaster says:

    This is a superb post .

    But I was wondering how do I suscribe to the RSS feed?

Leave a Reply

Wordpressapi is developer code book.
wordpressapi on Facebook
© 2010 Wordpressapi. All Rights Reserved. Reproduction without explicit permission is prohibited.