Prado\Caching\TDbCache::addValue PHP Method

addValue() protected method

This is the implementation of the method declared in the parent class.
protected addValue ( $key, $value, $expire ) : boolean
return boolean true if the value is successfully stored into cache, false otherwise
    protected function addValue($key, $value, $expire)
    {
        if (!$this->_cacheInitialized) {
            $this->initializeCache();
        }
        $expire = $expire <= 0 ? 0 : time() + $expire;
        $sql = "INSERT INTO {$this->_cacheTable} (itemkey,value,expire) VALUES(:key,:value,{$expire})";
        try {
            $command = $this->getDbConnection()->createCommand($sql);
            $command->bindValue(':key', $key, \PDO::PARAM_STR);
            $command->bindValue(':value', serialize($value), \PDO::PARAM_LOB);
            $command->execute();
            return true;
        } catch (\Exception $e) {
            try {
                $this->initializeCache(true);
                $command->execute();
                return true;
            } catch (\Exception $e) {
                return false;
            }
        }
    }