Phalcon\Cache\Backend\Wincache::save PHP Method

save() public method

public save ( string $keyName = null, string $content = null, integer $lifetime = null, boolean $stopBuffer = true ) : boolean
$keyName string
$content string
$lifetime integer
$stopBuffer boolean
return boolean
    public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true)
    {
        if ($keyName === null) {
            $lastKey = $this->_lastKey;
        } else {
            $lastKey = $this->getPrefixedIdentifier($keyName);
        }
        if (!$lastKey) {
            throw new Exception('The cache must be started first');
        }
        /** @var \Phalcon\Cache\FrontendInterface $frontend */
        $frontend = $this->getFrontend();
        if ($content === null) {
            $cachedContent = $frontend->getContent();
        } else {
            $cachedContent = $content;
        }
        $preparedContent = $frontend->beforeStore($cachedContent);
        if ($lifetime === null) {
            $lifetime = $this->_lastLifetime;
            if ($lifetime === null) {
                $ttl = $frontend->getLifetime();
            } else {
                $ttl = $lifetime;
            }
        } else {
            $ttl = $lifetime;
        }
        $status = wincache_ucache_set($lastKey, $preparedContent, $ttl);
        if (!$status) {
            throw new Exception('Failed storing data by using wincache');
        }
        $isBuffering = $frontend->isBuffering();
        if ($stopBuffer) {
            $frontend->stop();
        }
        if ($isBuffering) {
            echo $content;
        }
        $this->_started = false;
        return $status;
    }