Test if a cache is available for the given id and (if yes) return it (false else)

@param string $id cache id
@param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
@return string|false cached datas
973818
public function load($id, $doNotTestCacheValidity = false)
    {
        if (!($this->_test($id, $doNotTestCacheValidity))) {
            // The cache is not hit !
            return false;
        }
        $metadatas = $this->_getMetadatas($id);
        $file = $this->_file($id);
        $data = $this->_fileGetContents($file);
        if ($this->_options['read_control']) {
            $hashData = $this->_hash($data, $this->_options['read_control_type']);
            $hashControl = $metadatas['hash'];
            if ($hashData != $hashControl) {
                // Problem detected by the read control !
                $this->_log('Zend_Cache_Backend_File::load() / read_control : stored hash and computed hash do not match');
                $this->remove($id);
                return false;
            }
        }
        return $data;
    }
30810
protected function _id($id)
    {
        if (($id !== null) && isset($this->_options['cache_id_prefix'])) {
            return $this->_options['cache_id_prefix'] . $id; // return with prefix
        }
        return $id; // no prefix, just return the $id passed
    }
37335
public function isInCache($ID, $Verbose = false, $UpdateHitsCount = false)
    {
        /* Compute the paths */
        $Index = $this->CacheFolder . "/" . $this->CacheIndex;

        /* Search the picture in the index file */
        $Handle = @fopen($Index, "r");
        while (!feof($Handle)) {
            $IndexPos = ftell($Handle);
            $Entry = fgets($Handle, 4096);
            if ($Entry != "") {
                $Settings = preg_split("/,/", $Entry);
                $PicID = $Settings[0];
                if ($PicID == $ID) {
                    fclose($Handle);

                    $DBPos = $Settings[1];
                    $PicSize = $Settings[2];
                    $GeneratedTS = $Settings[3];
                    $Hits = intval($Settings[4]);

                    if ($UpdateHitsCount) {
                        $Hits++;
                        if (strlen($Hits) < 7) {
                            $Hits = $Hits . str_repeat(" ", 7 - strlen($Hits));
                        }

                        $Handle = @fopen($Index, "r+");
                        fseek($Handle, $IndexPos);
                        fwrite(
                            $Handle,
                            sprintf(
                                "%s,%s,%s,%s,%s\r\n",
                                $PicID,
                                $DBPos,
                                $PicSize,
                                $GeneratedTS,
                                $Hits
                            )
                        );
                        fclose($Handle);
                    }

                    if ($Verbose) {
                        return [
                            "DBPos" => $DBPos,
                            "PicSize" => $PicSize,
                            "GeneratedTS" => $GeneratedTS,
                            "Hits" => $Hits
                        ];
                    } else {
                        return true;
                    }
                }
            }
        }
        fclose($Handle);

        /* Picture isn't in the cache */
        return false;
    }
229741
public static function getCachedInfo($id, $key = null, $default = null)
    {
        $cacheKey = 'role:' . $id;
        try {
            $result = \Cache::remember($cacheKey, \Config::get('df.default_cache_ttl'), function () use ($id){
                $role = Role::with(
                    [
                        'role_service_access_by_role_id',
                        'service_by_role_service_access'
                    ]
                )->whereId($id)->first();

                if (empty($role)) {
                    throw new NotFoundException("Role not found.");
                }

                $roleInfo = $role->toArray();
                $services = array_get($roleInfo, 'service_by_role_service_access');
                unset($roleInfo['service_by_role_service_access']);

                foreach ($roleInfo['role_service_access_by_role_id'] as $key => $value) {
                    $serviceName = array_by_key_value(
                        $services,
                        'id',
                        array_get($value, 'service_id'), 'name'
                    );
                    $component = array_get($value, 'component');
                    $roleInfo['role_service_access_by_role_id'][$key]['service'] = $serviceName;
                    $roleInfo['role_service_access_by_role_id'][$key]['component'] = trim($component, '/');
                }

                return $roleInfo;
            });

            if (is_null($result)) {
                return $default;
            }
        } catch (ModelNotFoundException $ex) {
            return $default;
        }

        if (is_null($key)) {
            return $result;
        }

        return (isset($result[$key]) ? $result[$key] : $default);
    }
434665
public static function get($id, $cache = true) {
        if (!$id) {
            return null;
        }
        $model = get_called_class();
        $db_cache = null;
        if ($cache) {
            /* @var $db_cache DBCache */
            $db_cache = Ioc::get(DBCache::class);
            $data = $db_cache->recordCache($model, $id);
            if ($data) {
                return $data;
            }
        }
        /* @var $model Record */
        $model = new $model;
        $pk = $model->getPkField();
        $where[ $pk ] = $id;
        $data = $model::find($where);
        if ($cache && $data) {
            $db_cache->recordCacheSave(get_called_class(), $id, $data->_db_data);
        }
        return $data;
    }
1331998
public function has( $id ){
		if( $this->cache->has( $this->cacheKey.$id ) )
			return TRUE;
		return (bool) $this->get( $id );
	}
404083
public function read($id)
    {
        // Check if id exists
        if (!xcache_isset($this->prefix . $id)) {
            return false;
        }

        return (string) xcache_get($this->prefix . $id);
    }
469731
public function has($id) {
        $id = $this->normalizeID($id);

        return isset($this->instances[$id]) || !empty($this->rules[$id]) || class_exists($id);
    }
1370371
public function find($id)
    {
        if ($this->refresh) {
            $this->forget($id);
        }
        return $this->cache->remember($this->keyPrefix . $id . implode('-', $this->with), $this->minutesToCache,
            function () use ($id) {
                return $this->decorated->find($id);
            });
    }
638064
public function remove($id)
    {
        if (true === $result = @unlink($this->getCacheFile($id))) {
            $this->log('debug', sprintf('Cache data removed for id `%s`.', $id));
        }

        return $result;
    }
874779
function GetCache($type, $id) {
		if (!isset($this->cache[$type]) || !$this->cache[$type]) // Dont cache this type of call
			return FALSE;
		if (isset($this->_cache[$type][$id]))
			return $this->_cache[$type][$id];
		return FALSE;
	}
979316
public static function isValid($id)
    {
        $writeCache = false;
        $cacheId = 'media-isvalid-component-'.$id;
        $plugins = Kwf_Cache_Simple::fetch($cacheId, $success);
        if ($success) {
            //success means it's VALID and we successfully fetched the $plugins
            $ret = Kwf_Media_Output_IsValidInterface::VALID;
        } else {
            $ret = Kwf_Media_Output_IsValidInterface::VALID;
            $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id);
            if (!$c) {
                $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible'=>true));
                if (!$c) return Kwf_Media_Output_IsValidInterface::INVALID;
                if (Kwf_Component_Data_Root::getShowInvisible()) {
                    //preview im frontend
                    $ret = Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE;
                } else if (Kwf_Registry::get('acl')->isAllowedComponentById($id, $c->componentClass, Kwf_Registry::get('userModel')->getAuthedUser())) {
                    //paragraphs preview in backend
                    $ret = Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE;
                } else if (Kwf_Registry::get('acl')->isAllowedUser(Kwf_Registry::get('userModel')->getAuthedUser(), 'kwf_component_preview', 'view')) {
                    //perview user in frontend
                    $ret = Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE;
                } else {
                    return Kwf_Media_Output_IsValidInterface::ACCESS_DENIED;
                }
            }
            //$ret can be VALID or VALID_DONT_CACHE at this point

            $plugins = array();
            $onlyInherit = false;
            while ($c) {
                $p = Kwc_Abstract::getSetting($c->componentClass, 'pluginsInherit');
                if (!$onlyInherit) {
                    $p = array_merge($p, Kwc_Abstract::getSetting($c->componentClass, 'plugins'));
                }
                foreach ($p as $plugin) {
                    if (is_instance_of($plugin, 'Kwf_Component_Plugin_Interface_Login')) {
                        $plugins[] = array(
                            'plugin' => $plugin,
                            'id' => $c->componentId
                        );
                    }
                }
                if ($c->isPage) {
                    $onlyInherit = true;
                }
                $c = $c->parent;
            }

            if ($ret == Kwf_Media_Output_IsValidInterface::VALID) {
                //only cache VALID, VALID_DONT_CACHE can't be cached
                $writeCache = true;
            }
        }

        foreach ($plugins as $p) {
            $plugin = $p['plugin'];
            $plugin = new $plugin($p['id']);
            if ($plugin->isLoggedIn()) {
                $ret = Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE;
            } else {
                $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id);
                $userModel = Kwf_Registry::get('userModel');
                if (Kwf_Registry::get('acl')->isAllowedComponentById($id, $c->componentClass, $userModel ? $userModel->getAuthedUser() : null)) {
                    //allow preview in backend always
                    $ret = Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE;
                } else {
                    $ret = Kwf_Media_Output_IsValidInterface::ACCESS_DENIED;
                     break;
                }
            }
        }

        if ($writeCache && $ret == Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE) {
            //only cache VALID_DONT_CACHE, not VALID as it will be cached in Kwf_Media::getOutput
            //this cache doesn't need to be cleared, because of it's lifetime
            Kwf_Cache_Simple::add($cacheId, $plugins, 60*60-1); //one second less than isValid cache in Kwf_Media
        }
        return $ret;
    }
949266
public boolean isCacheIdInAuxDepIdTable(Object id) {
        if (delayOffload) {
            if (!this.disableDependencyId) {
                return this.auxDataDependencyTable.containsCacheId(id);
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
1056918
protected function _get($id)
	{
		if ( ! is_file($this->_cache_path.$id))
		{
			return FALSE;
		}

		$data = unserialize(file_get_contents($this->_cache_path.$id));

		if ($data['ttl'] > 0 && time() > $data['time'] + $data['ttl'])
		{
			unlink($this->_cache_path.$id);
			return FALSE;
		}

		return $data;
	}
537805
public function fetch( $id ) {

		if ( $this->contains( $id ) ) {
			$this->cacheHits++;
			return $this->inMemoryCache[ $id ];
		}

		$this->cacheMisses++;
		return false;
	}
1295203
public static function cache( int $id )
	{
		if( ! self::cacheIs($id) && $id === 0 )
		{
			$module = new ModuleCore();
			self::setCache(0, $module->setLoadedFromCache());
		}

		return self::defaultCache($id);
	}
965699
protected function assertValidId($id)
    {
        if (defined('PHP_WINDOWS_VERSION_BUILD')) {
            $bad = preg_match('/[\x00-\x1F\x7F]\<\>\:\"\|\?\*]/', $id);
        } else {
            $bad = preg_match('/\x00/', $id);
        }
        if ($bad) {
            throw new RawFileCacheException('Invalid character found in cache ID', RawFileCacheException::INVALID_CHARACTER);
        }
    }