Nette\Caching\Storages\SQLiteStorage::write PHP Method

write() public method

Writes item into the cache.
public write ( $key, $data, array $dependencies ) : void
$dependencies array
return void
    public function write($key, $data, array $dependencies)
    {
        $expire = isset($dependencies[Cache::EXPIRATION]) ? $dependencies[Cache::EXPIRATION] + time() : NULL;
        $slide = isset($dependencies[Cache::SLIDING]) ? $dependencies[Cache::EXPIRATION] : NULL;
        $this->pdo->exec('BEGIN TRANSACTION');
        $this->pdo->prepare('REPLACE INTO cache (key, data, expire, slide) VALUES (?, ?, ?, ?)')->execute([$key, serialize($data), $expire, $slide]);
        if (!empty($dependencies[Cache::TAGS])) {
            foreach ((array) $dependencies[Cache::TAGS] as $tag) {
                $arr[] = $key;
                $arr[] = $tag;
            }
            $this->pdo->prepare('INSERT INTO tags (key, tag) SELECT ?, ?' . str_repeat('UNION SELECT ?, ?', count($arr) / 2 - 1))->execute($arr);
        }
        $this->pdo->exec('COMMIT');
    }