why did memcache get expired everyday whereas i have set it to 0 as expiration time?

StackOverflow https://stackoverflow.com/questions/23491477

  •  16-07-2023
  •  | 
  •  

I dont know why is this happening. Everytime i set data like this-

    $mem = new Memcache();
    $mem->connect('localhost', 11211) or die ("Could not connect");     
    $userData=$mem->get("$USERID_DATA");
    if(!empty($userData)){
        $DATA=$userData;
        echo "COMMING FROM HOME";
    } else {
        $DATA=$modelUser->getUserData($USERID);
        $mem->set("$USERID_DATA",$DATA,MEMCACHE_COMPRESSED,0); // Never Expired
        echo "COMMING FROM MOON";
    }
    var_dump($DATA);

and next when i returned to see my data after login .. it printed all the data, but it gives me message COMMING FROM MOON

It means it gives me data from DB not from memcache.

Am i doing something wrong?

Please help..

有帮助吗?

解决方案

Every time you restart the machine the memcache daemon will go down and start again, resulting in loosing the stored data as memcached is an in memory store. So your previously stored data will not be there when you restart the machine.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top