public function save($data, $id, $tags = [], $specificLifetime = false)
{
$lifetime = $this->getLifetime($specificLifetime);
if (is_null($lifetime)) {
$lifetime = 86400 * 365;
}
$this->getDb()->beginTransaction();
try {
$this->getDb()->insertOrUpdate("cache", ["data" => $data, "id" => $id, "expire" => time() + $lifetime, "mtime" => time()]);
if (count($tags) > 0) {
while ($tag = array_shift($tags)) {
$this->getDb()->insertOrUpdate("cache_tags", ["id" => $id, "tag" => $tag]);
}
}
$this->getDb()->commit();
} catch (\Exception $e) {
Logger::error($e);
$this->getDb()->rollBack();
$this->truncate();
return false;
}
return true;
}