yii\caching\FileCache::getValue PHP Method

getValue() protected method

This is the implementation of the method declared in the parent class.
protected getValue ( string $key ) : string | false
$key string a unique key identifying the cached value
return string | false the value stored in cache, false if the value is not in the cache or expired.
    protected function getValue($key)
    {
        $cacheFile = $this->getCacheFile($key);
        if (@filemtime($cacheFile) > time()) {
            $fp = @fopen($cacheFile, 'r');
            if ($fp !== false) {
                @flock($fp, LOCK_SH);
                $cacheValue = @stream_get_contents($fp);
                @flock($fp, LOCK_UN);
                @fclose($fp);
                return $cacheValue;
            }
        }
        return false;
    }

Usage Example

Example #1
0
 protected function getValue($key)
 {
     $value = base64_decode(parent::getValue($key));
     return $value;
 }
All Usage Examples Of yii\caching\FileCache::getValue