
Thinking of implementing caching for your php application , you are at a right place. Just in 10 simple (copy and paste) steps you can install and access Memcached Server.
Step1: Install libevent ,libmemcached and libmemcached devel (dependency)
1
2
| yum install libevent
yum install libmemcached libmemcached-devel |
.
Step 2: Install Memcached Server
.
Step 3: Start Memcached server
1
| memcached -d -m 512 -l 127.0.0.1 -p 11211 -u nobody |
(d = daemon, m = memory, u = user, l = IP to listen to, p = port)
.
Step 4: Check your memcached server is running successfully
1
| ps -eaf | grep memcached |
.
Step 5: Connect Memcached server via telnet
.
Step 6: Check current status of Memcached Server on telnet prompt
.
Step 7: Exit telnet
.
Step 8: Install PHP client to access Memcached Server
It will make “memcache.so”, you have to just put it on your /etc/php.ini file.
.
Step 9: Restart your apache server
.
Step 10: Open your favorite editor to type below code and execute it, it will cache your data into Memcached server and access it back for you
1
2
3
4
5
6
7
8
9
10
11
12
| <?php
$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211) or die ("Could not connect"); //connect to memcached server
$mydata = "i want to cache this line"; //your cacheble data
$memcache->set('key', $mydata, false, 100); //add it to memcached server
$get_result = $memcache->get('key'); //retrieve your data
var_dump($get_result); //show it
?> |
.
Hurray!! All done!
Enjoy Caching with Memcached.
Cheers!
We offer guaranteed
650-393 exam preparation with self paced
70-272 study guide and
1z0-051 dumps!
Comments
For example, CentOS does not have Memcached in its repository, so you should use RPMForge (http://wiki.centos.org/AdditionalResources/Repositories/RPMForge) or other repo.
BTW, when you use only one server (localhost), it’s better to use APC or XCache because they don’t open TCP connection.
This post is over-explained,rightly said Baby steps. in reality however you need 4 steps Max.
Cheers !!
really useful! thanks!
install too long
I am to a great extent impressed with the article I have just read. I wish the author of webdeveloperjuice can continue to provide so much useful information and unforgettable experience to its readers. There is not much to state except the following universal truth: No matter how much you dumb down something, someone out there is dumber. I will be back.
me to go somewhere dutch, I’ll brain you.”
“Please keep it. I have several like it,” said Petya, blushing.
and forth-their own CB now in easy reaching distance-there were over three
“That it would be hard for them to make a mistake,” Stu finished for him.
xjRrB3 Excellent article, I will take note. Many thanks for the story!
Nice article.
I would recommend using the newer Memcached PHP library instead of the older ‘Memcache-without-the-d’lib. The newer one is a lot faster and manages connections much faster.
The older library still shows up first in Google results, so here’s the link:
http://php.net/manual/en/book.memcached.php
-mike
“That it would be hard for them to make a mistake,” Stu finished for him.
I think a nice blog
Hi administrator I enjoy w/ ur article . might i copy this knowledge as my academic check ? thanks
Hello dude,i likes Ones website in truth much. achieve u allow suggestion for my site? thanks for Ones New attention
Hello dude,i likes Your New website in truth a lot. achieve u have on suggestion being my website? thanks as Your attention
Hello dude,i like this Your New site ideal a lot. attain u have on suggestion as my site? thanks as Ones New attention
Hello dude,i like this Your homepage ideal a lot. achieve u have suggestion for my website? thanks being Your attention
Hello dude,i liking A New blog very much. accomplish u allow suggestion for my homepage? thanks for Your New attention
Hello dude,i liking Your site ideal much. do u have suggestion being my site? thanks being Ones New attention
Hello dude,i like this A New blog ideal a lot. accomplish u have suggestion as my website? thanks being Ones attention
Hello dude,i like A New website very a lot. attain u have on suggestion as my blog? thanks being Your attention
You are the man ! good bye
Great news brother
Hello dude,i likes Your homepage ideal a lot. attain u allow suggestion for my homepage? thanks being Ones attention
where did u get this know-how
hey!!!!!!!!!!!!!!!!!look!!!!
I likes Your style boy
effective luck for you
Hay Dude , i with ur web blog. LOL Please come to my blog
hey Dude , i read w/ u write. LOL Please come to my blog
Sorry for the huge review, but I’m really loving the new Zune, and hope this, as well as the excellent reviews some other people have written, will help you decide if it’s the right choice for you.
Very impressive article, I am really a fanatic reader of your blog
Thanks for sharing, I like this blog!
Hey I just now stumbled upon your website right from aol and I really wanted to mention what a terrific article this was! Having said that, I am attempting to add your current RSS feed however I am having difficulty discovering it.
I was surprised the amount of this I did not fully understand. Thank you for posting this info. I’ll be certain to come back right here to find if there’s any kind of brand new content.
Great blog, I am really liking the styling and format, Can I ask what theme are you using for this blog?
Dude you legend. Come and look at my site, you should enjoy it.
Just wanted to say, it’s all good really.
Seeing that i have been exploring temporarly for a pleasant study with reference to this one topic . Researching in Yahoo I lastly came across this web site. Reading these details I am relieved to convey that I get a good uncanny feeling I came across precisely what I needed. I most certainly will make sure to remember this web-site and check it out consistently.
It was a fascinating piece of content. But I’m experiencing difficulty getting your website to show up properly for this internet explorer browser, any kind of suggestion for what could be creating the problem??
i was surprised at just how much on this I did not fully understand. Many thanks for sharing this post. I will be sure to return here to check out if there is any brand new articles.