Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't connect to memcache

I am trying to connect to memcache as they suggest:

$memcache = new Memcache();
$memcache->pconnect('localhost',11211);

But i get:

Notice: Memcache::pconnect() [memcache.pconnect]: Server localhost (tcp 11211) failed with: Connection refused (111) in /home/user/public_html/website.com/includes/basedatos.php on line 26

Any idea why?

like image 263
Toni Michel Caubet Avatar asked May 27 '12 18:05

Toni Michel Caubet


People also ask

What happens when memcache is full?

From the memcached wiki: When the table is full, subsequent inserts cause older data to be purged in least recently used (LRU) order.


2 Answers

You need to actually install the memcached server so that it can be connected to. On CentOS, this can be done with...

sudo yum install memcached

(on debian flavors of linux, use apt-get instead of yum)

like image 78
Amber Avatar answered Sep 21 '22 15:09

Amber


This may be obvious, but make sure that memcached is actually running:

service memcached start
like image 26
Andrew Rout Avatar answered Sep 20 '22 15:09

Andrew Rout