Pop\Cache\Adapter\Sqlite::save PHP Метод

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

Method to save a value to cache.
public save ( string $id, mixed $value, string $time ) : void
$id string
$value mixed
$time string
Результат void
    public function save($id, $value, $time)
    {
        $time = time() + (int) $time;
        // Determine if the value already exists.
        $this->sqlite->select()->where()->equalTo('id', ':id');
        $this->sqlite->adapter()->prepare($this->sqlite->render(true))->bindParams(array('id' => sha1($id)))->execute();
        $rows = array();
        while (($row = $this->sqlite->adapter()->fetchResult()) != false) {
            $rows[] = $row;
        }
        // If the value exists, update it.
        if (count($rows) > 0) {
            $this->sqlite->update(array('value' => ':value', 'time' => ':time'))->where()->equalTo('id', ':id');
            $params = array('value' => serialize($value), 'time' => $time, 'id' => sha1($id));
            // Else, save the new value.
        } else {
            $this->sqlite->insert(array('id' => ':id', 'value' => ':value', 'time' => ':time'));
            $params = array('id' => sha1($id), 'value' => serialize($value), 'time' => $time);
        }
        $this->sqlite->adapter()->prepare($this->sqlite->render(true))->bindParams($params)->execute();
    }