Sefam
Sefam

Reputation: 1773

PHP Memcached set always returns false

Here is the status of my memcached php extension on my Godaddy server;

enter image description here

And memcached seems to be running properly on the server, it is present in the ps -aux list;

enter image description here

I'm using this PHP script to test memcached;

error_reporting(E_ALL|E_STRICT);

ini_set('display_errors', true);

$mem = new memcached();

$mem->addServer("127.0.0.1", 11211);

$result = $mem->get("Test");

if ($result) {

echo $result;

} else {

echo "Test key not found, adding key";

$mem->set("Test", "I found a match, memcache is working") or die("Nothing Saved...");

}

I have no idea whether I'm doing something wrong or not, but memcached seems to be unable to set anything.

Upvotes: 1

Views: 2549

Answers (1)

Mark Brown
Mark Brown

Reputation: 914

The ps -aux shows memcache is on port 3452. Try changing:

$mem->addServer("127.0.0.1", 11211);

to:

$mem->addServer("127.0.0.1", 3452);

Upvotes: 2

Related Questions