Warning: Memcache::connect(0memcache.connect0): Can't connect to localhost:11211, Connection refuse
Posted
by Stick it to THE MAN
on Stack Overflow
See other posts from Stack Overflow
or by Stick it to THE MAN
Published on 2010-03-09T01:19:20Z
Indexed on
2010/03/09
1:21 UTC
Read the original article
Hit count: 545
I am using Symfony 1.3.2 with Propel ORM on Ubuntu 9.10.
I am incorporating memcache to the website.
I have modified the setup() method in apps/frontend/ProjectConfiguration.class.php like this:
class ProjectConfiguration
{
public function setup()
{
// original SF generated code here ..
require_one sfConfig::get('sf_lib_dir').'/MyCache.class.php';
myCache::init();
}
}
my cache singleton is implemented something like this:
class MyCache
{
private static memcache = null;
private static inited = false;
public static init()
{
if (self::$inited) return;
self::$memcache = new Memcache();
if (self::$memcache->connect('localhost', 11211)
{
// Do some stuff ..
self::$inited = true;
}
}
}
Warning: Memcache::connect(0memcache.connect0): Can't connect to localhost:11211, Connection refused(111) in /path_to_class/MyCache.class.php
This happens for both CLI (e.g. running SF tasks) or for web access through the browser.
Does anyone know how to resolve this (I suspect its something to do with Linux user privileges).
As an aside, I am aware that SF prvoides an sfAPCache wrapper class for cacheing.
I am intentionally not using it for two reasons:
- I cannot find any comprehensive (and up to date) docs on this class
- I want to learn the memcache API directly, since I will be accesing it from other languages.
© Stack Overflow or respective owner