Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've installed memcached perfectly and i can created a new instance but i don't understand if I'm connection to the right port... I always get a false return from get(key) Here is my code,

    $sql = "SELECT * FROM users";
    $key = md5('q'.$sql); //create an index key for memcache
    $result = $memcache->get($key);//lookup value in memcache
    //check if we got something back
    if($result == null) {
        echo "nothing back";
        $r = mysql_query($sql) or die(mysql_error()." : $sql");//fetch from database
        if(mysql_num_rows($r)> 0) {
        echo "returned";
            $people = array();
            while ($person = mysql_fetch_assoc($r)) {
                $people[] = $person;
            }
            $memcache->set($key,$people,0,3600);//store in memcache
        }
    }
    print_r($result);
share|improve this question

2 Answers 2

Here is the connect statement $memcache = new Memcache; $memcache->connect('127.0.0.1',11211) or die ("Could not connect");

you dont have a memcached connect statement.

Memcached default port is widely considered 11211.

use something like http://livebookmark.net/memcachephp/memcachephp.zip to test your memcached/php install.

share|improve this answer
    
This is the connect statement I'm using $memcache = new Memcache; $memcache->connect('127.0.0.1',11211) or die ("Could not connect"); –  user851171 Aug 11 '11 at 17:33
    
still having problems with this? –  GruffTech Sep 19 '11 at 17:07

By the default, memcached listen on port 11211. Which port you use to connect and what's the exactly error you get?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.