We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Model Caching - Invalid Serialization Data

I have a table in MySQL with the row and column setup as:

table_name:
ID: 1
board: 1; 
user: 1;

I have the following code in a controller:

$frontCache = new Phalcon\Cache\Frontend\Data(array(
    "lifetime" => 172800
));
$cache = new Phalcon\Cache\Backend\File($frontCache, array(
    "cacheDir" => "/tmp/"
));
$cacheKey = 'robots_order_id.cache';
$robots    = $cache->get($cacheKey);
if ($robots === null) {
    $robots = Table_name::find(array("order" => "ID"));
    $cache->save($cacheKey, $robots);
}
foreach ($robots as $robot) {
   echo $robot->ID, "\n";
}

I keep getting the following error:

Phalcon\Mvc\Model\Exception: Invalid serialization data

Can someone explain why this is happening?

What version are you using?

Hi,

1.3.5 I think. We are not using version 2.0.

Thanks