Cache_Lite Bug on Resave?

From: Date: Thu, 20 Feb 2003 12:43:41 +0000
Subject: Cache_Lite Bug on Resave?
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-3857@lists.php.net to get a copy of this message
Hi, I seem to be running into some trouble with Cache_Lite upon resaving data for caching. The below script demonstrates the problem. I am using Cache_lite with read and write checking. ---------------- if ($data = $cache->get('test')) {
    var_dump($data = unserialize($data));
    // Success
    $data->now();
    $cache->save(serialize($data), 'test');
    // Failure
} else {
    $data = new test();
    $cache->save(serialize($data), 'test');
    // Success
} class test {
    var $now = null;
    var $then = null;
    function test()
    {
        $this->then = time();
    }
    function now()
    {
         $this->now = time();
    }
} ----------------- For some reason that is totally escaping me, when doing the read control, it fails: line 341:
$hashControl = "                      -155960464"
//Correct line 344: $data = @fread($fp, $length); // Incorrect, it only reads in a incomplete amount of the data $data = "O:4:"test":2:{s:3:"now";i:1045743845;s:4:"then";i:1"; // It should be $data_in_reality = "O:4:"test":2:{s:3:"now";i:1045743845;s:4:"then";i:1045743833;}"; // And hashData is incorrectly evaluated to
$hashData = "                     -1334859930"
What puzzles me is that when doing the initial $cache->save(), it works absolutely fine. Why is it that my recaching fails? Thanks, Michael

« previous php.pear.general (#3857) next »