yii\caching\DbCache::addValue PHP Method

addValue() protected method

This is the implementation of the method declared in the parent class.
protected addValue ( string $key, string $value, integer $duration ) : boolean
$key string the key identifying the value to be cached
$value string the value to be cached. Other types (if you have disabled [[serializer]]) cannot be saved.
$duration integer the number of seconds in which the cached value will expire. 0 means never expire.
return boolean true if the value is successfully stored into cache, false otherwise
    protected function addValue($key, $value, $duration)
    {
        $this->gc();
        try {
            $this->db->createCommand()->insert($this->cacheTable, ['id' => $key, 'expire' => $duration > 0 ? $duration + time() : 0, 'data' => [$value, \PDO::PARAM_LOB]])->execute();
            return true;
        } catch (\Exception $e) {
            return false;
        }
    }