Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7536117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:29:19+00:00 2026-05-30T06:29:19+00:00

My problem is that memcache logic inside my cakePHP application is not working on

  • 0

My problem is that memcache logic inside my cakePHP application is not working on my local system, ever since I set it up here, by taking code from existing setup of teammates. I have checked that Memcached service is running on my system and phpinfo() shows memcache section enabled.

But, things like these are not working –

$this->Memcache->set($key,$value);

CakePHP uses its wrapper for Memcache, v. 0.3.

If I debug like this –

echo "<pre>";
echo "checking";
error_reporting(-1); 
$this->Memcache->set($key,$countryNetworkWiseReportData,3600);
echo "finished";
exit;

I get –

checkingfinished
Strict standards: Non-static method Cache::write() should not be called statically, assuming $this from incompatible context in D:\cake1.2\cake\libs\configure.php on line 690

… and similar strict standard notifications for Cache::getInstance() etc.

But note the notifications appear after "checkingfinished", so I am confused if that is actually relevant.

I tried the command –

telnet 127.0.0.1:11211

Which gives –

Connecting To 127.0.0.1:11211...Could not open connection to the host, on port 23: Connect failed

Also tried –

telnet localhost:11211 (in case firewall issues prevent connection to 127.0.0.1)

But got the same error.

I also tried this script called memcache.php. I put $arr= "127.0.0.1:11211"; in the code and I got this result on my system –

enter image description here

What do I interpret from this data? I am getting a Warning in the Start time section – Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the ....

So far, it appears to me that connection to the default port 11211 is due to some reason not allowed in my cakePHP project code. But again, how then memcache.php is able to connect to the memcache server and able to display those data.

Further Details

Thanks to Tudor Constantin, doing telnet 127.0.0.1 11211 does not throw any error anymore, shows an empty screen… which I guess is fine.

I checked further in code, we have model functions which have logic like this –

if(!$this->memcacheCommon())
{
    $this->log('Error in memcache', LOG_DEBUG);
    die('Error in memcache');
}

//like in others system, in my system too, it passes above condition

$memcachedata = $this->Memcache->get($key);
//does not return data in my system, because $this->Memcache->set($key,$data); never sets the data correctly.

if(got data from memcache)
{
    //Return that data
}
else
{
    //Get data from database
    $this->Memcache->set($key,$data); //does not the data in my setup - set() function returns false
}

So, I went inside the set() function of class CakeMemcache(), and there is this line in the end

return @$this->_Memcache_cluster_new->set($key, $var, 0, time()+$expires);

this returns false, and I don’t know what to debug from here.

One more thing that is confusing me is memcacheCommon() inside app_model.php has these lines –

$this->Memcache = new CakeMemcache();
$this->Memcache->_connect();

And inside CakeMemcache()->_connect(), there are these lines –

$this->_Memcache_standalone =& new Memcache();
$this->_Memcache_cluster_new =& new Memcache();

I am not sure what exactly do they do.

Will appreciate any pointers… thanks

More Details

I have somehow lost the earlier memcache.php file, using which I got the above graphical memcache usage display (had posted the pic of the output I got, above). I later downloaded memcache-3.0.6 from http://pecl.php.net/package/memcache/3.0.6 and tried running the example.php and memcache.php files which are present inside the archive.

Firstly, running example.php gives me following error –

Notice: memcache_connect(): Server localhost (tcp 11211) failed with: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Warning: memcache_connect(): Can't connect to localhost:11211, A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Connection to memcached failed

I checked that memcached service is running (in windows services list).
Also telnet localhost 11211 does not give any error and shows an empty command window.

Secondly, running memcache.php and entering the credentials, gives me the following, on clicking all the tabs (Refresh Data, View Host stats, variables ) –

Notice: Use of undefined constant values - assumed 'values' in path\to\file\memcache.php on line 57
Cant connect to:v:a

Line 57 was –

function get_host_port_from_server($server){
    $values = explode(':', $server);
    if (($values[0] == 'unix') && (!is_numeric( $values[1]))) {
        return array($server, 0);
    }
    else {
        return values;   //line 57
    }
}

How come that was values, I downloaded it from http://pecl.php.net/package/memcache/3.0.6. After I changed it to return $values; I got ->

Cant connect to:mymemcache-server1:11211

. I don’t exactly remember how earlier I was able to get that memcache server graph (I posted the pic above).

Thirdly, on command line, after connecting via telnet, command stats gives the following –

STAT pid 1584
STAT uptime 2856
STAT time 1315981346
STAT version 1.2.1
STAT pointer_size 32
STAT curr_items 0
STAT total_items 0
STAT bytes 0
STAT curr_connections 1
STAT total_connections 3
STAT connection_structures 2
STAT cmd_get 0
STAT cmd_set 0
STAT get_hits 0
STAT get_misses 0
STAT bytes_read 7
STAT bytes_written 0
STAT limit_maxbytes 67108864
END
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:29:20+00:00Added an answer on May 30, 2026 at 6:29 am

    Yay! I found the solution!! It started working after I changed localhost to 127.0.0.1 in the /app/config/fcore.php file.

    Made the following changes –

    # Memcache server constants
    define('MEMCACHE_SERVER', 'localhost:11211');
    define('MEMCACHE_SERVER_CLUSTER', 'localhost:11211');
    define('MEMCACHE_SERVER_CLUSTER_NEW', 'localhost:11211');
    

    to

    # Memcache server constants
    define('MEMCACHE_SERVER', '127.0.0.1:11211');
    define('MEMCACHE_SERVER_CLUSTER', '127.0.0.1:11211');
    define('MEMCACHE_SERVER_CLUSTER_NEW', '127.0.0.1:11211');
    

    Oh, I suffered so much due to this and I think I could not, in my life, fix this.

    Luckily, our team setup a new repository for the project with 127.0.0.1 instead of localhost and when I took checkout memcache started working and later I realized this was the reason.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I been working on porting my application on Rails 3.0.7 ,ever since I started
Im using memcache to store a json, and it's working. But the problem is
One problem that I come across regularly and yet don't have a solution to
A problem that we need to solve regularly at my workplace is how to
The problem that I am having has to do with the need to keep
A problem that has frequently come up in my career is I have some
Simple problem that I can't figure out... How can I print a '%' character
I have a problem that confuses my users, being that although an item is
This has been a problem that I haven't been able to figure out for
I have the problem that an specific step in Ant can only be executed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.