Pimcore\Cache\Backend\MysqlTable::save PHP Метод

save() публичный Метод

Note : $data is always "string" (serialization is done by the core not by the backend)
public save ( string $data, string $id, array $tags = [], integer $specificLifetime = false ) : boolean
$data string Datas to cache
$id string Cache id
$tags array Array of strings, the cache record will be tagged by each string entry
$specificLifetime integer If != false, set a specific lifetime for this cache record (null => infinite lifetime)
Результат boolean True if no problem
    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;
    }