Check if the association must be flush the cache.

@param array $mapping The mapping

@return bool
197838
protected function isRequireAssociation(array $mapping)
    {
        $ref = new \ReflectionClass($mapping['sourceEntity']);

        if (\in_array(RoleHierarchicalInterface::class, $ref->getInterfaceNames(), true)
                && 'children' === $mapping['fieldName']) {
            return true;
        }

        if (\in_array(GroupableInterface::class, $ref->getInterfaceNames(), true)
                && 'groups' === $mapping['fieldName']) {
            return true;
        }

        return false;
    }
547036
public function flush($force = false, $key = null)
    {
        if (! isset($this->flushed[$key]) && ($force || $this->needsToFlush())) {
            try {
                $this->forceFlush($key);
            } catch (Exception $exception) {
                report($exception);
            }

            $this->flushed[$key] = true;
        }
    }
1012908
public function flush() {
    $request = new MemcacheFlushRequest();
    $response = new MemcacheFlushResponse();

    try {
      ApiProxy::makeSyncCall('memcache', 'FlushAll', $request, $response);
    } catch (Error $e) {
      return false;
    }
    return true;
  }
1114091
public function flush()
    {
        $this->initializeOnDemand();

        if ($this->cacheMapper->flush()) {
            // Reset the current state as well
            $this->cache = array();
            return true;
        } else {
            return false;
        }
    }
248704
private function cacheIsStale($cache)
    {
        if (!$cache) {
            return true;
        }

        $updated = $cache['updated'];
        foreach ($cache['files'] as $import => $mtime) {
            $filemtime = filemtime($import);

            if ($filemtime !== $mtime || $filemtime > $updated) {
                return true;
            }
        }

        return false;
    }
158324
protected function parseMapping(array $mapping) {
        foreach ($mapping['properties'] as $i => $property) {
            $name = $property['name'];
            $type = $property['type'];

            if (!isset($property['column'     ])) $property['column'     ] = $name;
            if (!isset($property['column-type'])) $property['column-type'] = $type;     // TODO: bug, $type may be a custom type

            if (isset($property['primary']) && $property['primary']===true)
                $mapping['identity'] = &$property;

            if (isset($property['version']) && $property['version']===true)
                $mapping['version'] = &$property;

            $column = $property['column'];
            $mapping['columns'][$column] = &$property;

            if ($type=='bool' || $type=='boolean') {
                $mapping['getters']['is'.$name ] = &$property;
                $mapping['getters']['has'.$name] = &$property;
            }
            else {
                $mapping['getters']['get'.$name] = &$property;
            }
            $mapping['properties'][$name] = &$property;
            unset($mapping['properties'][$i], $property);
        };

        if (isset($mapping['relations'])) {
            foreach ($mapping['relations'] as $i => $property) {
                $name  = $property['name' ];
                $assoc = $property['assoc'];

                // any association using a mandatory or optional join table
                if ($assoc=='many-to-many' || isset($property['join-table'])) {
                    if (!isset($property['join-table']))                       throw new RuntimeException('Missing attribute "join-table"="{table_name}" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                    if (!isset($property['key']))
                        $property['key'] = $mapping['identity']['name'];
                    else if (!isset($mapping['properties'][$property['key']])) throw new RuntimeException('Illegal attribute "key"="'.$property['key'].'" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                    if (!isset($property['ref-column']))                       throw new RuntimeException('Missing attribute "ref-column"="{'.$property['join-table'].'.column_name}" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                    if (!isset($property['fk-ref-column']))                    throw new RuntimeException('Missing attribute "fk-ref-column"="{'.$property['join-table'].'.column_name}" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                }

                // one-to-one (using no optional join table)
                else if ($assoc == 'one-to-one') {
                    if (!isset($property['column'])) {
                        if (!isset($property['key']))
                            $property['key'] = $mapping['identity']['name'];
                        else if (!isset($mapping['properties'][$property['key']])) throw new RuntimeException('Illegal attribute "key"="'.$property['key'].'" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                        if (!isset($property['ref-column']))                       throw new RuntimeException('Missing attribute "ref-column"="{column_name}" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                    }
                }

                // one-to-many (using no optional join table)
                else if ($assoc == 'one-to-many') {
                    if (!isset($property['key']))
                        $property['key'] = $mapping['identity']['name'];
                    else if (!isset($mapping['properties'][$property['key']])) throw new RuntimeException('Illegal attribute "key"="'.$property['key'].'" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                    if (!isset($property['ref-column']))                       throw new RuntimeException('Missing attribute "ref-column"="{column_name}" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                }

                // many-to-one (using no optional join table)
                else if ($assoc == 'many-to-one') {
                    if (!isset($property['column'])) throw new RuntimeException('Missing attribute "column"="{column_name}" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                }
                else                                 throw new RuntimeException('Illegal attribute "assoc"="'.$assoc.'" in relation [name="'.$name.'"...] of entity class "'.$mapping['class'].'"');

                if (isset($property['column']))
                    $mapping['columns'][$property['column']] = &$property;
                $getter = 'get'.$name;
                $mapping['getters'][$getter] = &$property;
                $mapping['relations'][$name] = &$property;
                unset($mapping['relations'][$i], $property);
            };
        }
        else $mapping['relations'] = [];

        $mapping['columns'] = \array_change_key_case($mapping['columns'], CASE_LOWER);
        $mapping['getters'] = \array_change_key_case($mapping['getters'], CASE_LOWER);

        return $mapping;
    }
1074587
protected function _validateAndCompleteOneToManyMapping(array $mapping)
    {
        $mapping = $this->_validateAndCompleteAssociationMapping($mapping);

        // OneToMany-side MUST be inverse (must have mappedBy)
        if ( ! isset($mapping['mappedBy'])) {
            throw MappingException::oneToManyRequiresMappedBy($mapping['fieldName']);
        }

        $mapping['orphanRemoval']   = isset($mapping['orphanRemoval']) ? (bool) $mapping['orphanRemoval'] : false;
        $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] ? true : $mapping['isCascadeRemove'];

        if (isset($mapping['orderBy'])) {
            if ( ! is_array($mapping['orderBy'])) {
                throw new InvalidArgumentException("'orderBy' is expected to be an array, not ".gettype($mapping['orderBy']));
            }
        }

        return $mapping;
    }
1068573
public function containsKey($key)
    {
        if (!$this->enabled)
            return false;

        $has_key = file_exists($this->file($key));

//        $this->Logger->debug("Cache contains {$key}? " . ($has_key) ? 'TRUE' : 'FALSE');

        return $has_key;
    }
659180
private function applyStorageStrategy(array &$mapping) : void
    {
        if (! isset($mapping['type']) || isset($mapping['id'])) {
            return;
        }

        switch (true) {
            case $mapping['type'] === 'int':
            case $mapping['type'] === 'float':
                $defaultStrategy   = self::STORAGE_STRATEGY_SET;
                $allowedStrategies = [self::STORAGE_STRATEGY_SET, self::STORAGE_STRATEGY_INCREMENT];
                break;

            case $mapping['type'] === 'many':
                $defaultStrategy   = CollectionHelper::DEFAULT_STRATEGY;
                $allowedStrategies = [
                    self::STORAGE_STRATEGY_PUSH_ALL,
                    self::STORAGE_STRATEGY_ADD_TO_SET,
                    self::STORAGE_STRATEGY_SET,
                    self::STORAGE_STRATEGY_SET_ARRAY,
                    self::STORAGE_STRATEGY_ATOMIC_SET,
                    self::STORAGE_STRATEGY_ATOMIC_SET_ARRAY,
                ];
                break;

            default:
                $defaultStrategy   = self::STORAGE_STRATEGY_SET;
                $allowedStrategies = [self::STORAGE_STRATEGY_SET];
        }

        if (! isset($mapping['strategy'])) {
            $mapping['strategy'] = $defaultStrategy;
        }

        if (! in_array($mapping['strategy'], $allowedStrategies)) {
            throw MappingException::invalidStorageStrategy($this->name, $mapping['fieldName'], $mapping['type'], $mapping['strategy']);
        }

        if (isset($mapping['reference']) && $mapping['type'] === 'many' && $mapping['isOwningSide']
            && ! empty($mapping['sort']) && ! CollectionHelper::usesSet($mapping['strategy'])) {
            throw MappingException::referenceManySortMustNotBeUsedWithNonSetCollectionStrategy($this->name, $mapping['fieldName'], $mapping['strategy']);
        }
    }
1266715
protected function _validateAndCompleteFieldMapping(array &$mapping)
    {
        // Check mandatory fields
        if ( ! isset($mapping['fieldName']) || strlen($mapping['fieldName']) == 0) {
            throw MappingException::missingFieldName($this->name);
        }
        if ( ! isset($mapping['type'])) {
            // Default to string
            $mapping['type'] = 'string';
        }

        // Complete fieldName and columnName mapping
        if ( ! isset($mapping['columnName'])) {
            $mapping['columnName'] = $this->namingStrategy->propertyToColumnName($mapping['fieldName'], $this->name);
        }

        if ($mapping['columnName'][0] === '`') {
            $mapping['columnName']  = trim($mapping['columnName'], '`');
            $mapping['quoted']      = true;
        }

        $this->columnNames[$mapping['fieldName']] = $mapping['columnName'];
        if (isset($this->fieldNames[$mapping['columnName']]) || ($this->discriminatorColumn != null && $this->discriminatorColumn['name'] == $mapping['columnName'])) {
            throw MappingException::duplicateColumnName($this->name, $mapping['columnName']);
        }

        $this->fieldNames[$mapping['columnName']] = $mapping['fieldName'];

        // Complete id mapping
        if (isset($mapping['id']) && $mapping['id'] === true) {
            if ($this->versionField == $mapping['fieldName']) {
                throw MappingException::cannotVersionIdField($this->name, $mapping['fieldName']);
            }

            if ( ! in_array($mapping['fieldName'], $this->identifier)) {
                $this->identifier[] = $mapping['fieldName'];
            }
            // Check for composite key
            if ( ! $this->isIdentifierComposite && count($this->identifier) > 1) {
                $this->isIdentifierComposite = true;
            }
        }

        if (Type::hasType($mapping['type']) && Type::getType($mapping['type'])->canRequireSQLConversion()) {
            if (isset($mapping['id']) && $mapping['id'] === true) {
                 throw MappingException::sqlConversionNotAllowedForIdentifiers($this->name, $mapping['fieldName'], $mapping['type']);
            }

            $mapping['requireSQLConversion'] = true;
        }
    }
458757
private function determineMaxValue(array $mapping)
    {
        if (!isset($mapping['precision']) && !isset($mapping['scale'])) {
            return null;
        }

        $scale = isset($mapping['scale']) ? (int)$mapping['scale'] : 0;
        $precision = isset($mapping['precision']) ? (int)$mapping['precision'] : 0;
        if ($precision < $scale) {
            $precision = $scale;
        }

        $maxValueStr = (int)str_repeat('9', $precision);
        $integerPartLength = $precision - $scale;

        $fractionalPart = substr($maxValueStr, 0, $integerPartLength);
        $integerPart = substr($maxValueStr, $integerPartLength);
        $maxValue = (float)"$fractionalPart.$integerPart";

        return $maxValue;
    }
1337046
public function flush() {
		$pattern = $this->getCachePath() . DIRECTORY_SEPARATOR . $this->prefix . '_*';
		
		if (self::isExecAvailable()) {
			exec('rm ' . $pattern);
			return true;
		}
		
		$list = glob($pattern);
		
		if ($list === false) {
			return false;
		}
		
		if (empty($list)) {
			return true;
		}
		
		$result = true;
		
		foreach ($list as $path) {
			if (! unlink($path)) {
				$result = false;
			}
		}
		
		return $result;
	}
207676
public function has($key)
    {
        //~ Check if enabled
        if (!$this->isEnabled()) {
            return false;
        }

        //~ Clear expired Cache files
        $this->clearExpired();

        $key = $this->prefix() . $key;

        return isset($this->cache[$key]);
    }
1061627
public function isInCache($key)
  {
    $value = $this->memcache->get($this->buildMKey($key));
    if ($value) {
      return true;
    }
    return false;
  }
26848
protected static function allowFromCache($condition) {
        if (self::enableCache() && is_array($condition) && count($condition) == 1) {
            $keys = array_keys($condition);
            if ($keys[0] == static::$pk) {
               return true;
            }
        }
        return false;
    }
639074
public function hasKey($key, $collection)
    {
        if (empty($this->queriesResultCache[ 'collectionKeys' ][ $collection ])) {
            $this->getKeys($collection);
        }

        return (bool)in_array($key, $this->queriesResultCache[ 'collectionKeys' ][ $collection ]);
    }
1277338
private function determineMaxValue(array $mapping)
    {
        $defaultMax = 2000000000;

        $lengthUndefined = !isset($mapping['length']);
        if ($lengthUndefined) {
            return $defaultMax;
        }

        $lengthInvalid = $mapping['length'] < 1
            || $mapping['length'] >= strlen($defaultMax);
        if ($lengthInvalid) {
            return $defaultMax;
        }

        $maxValue = (int)str_repeat('9', $mapping['length']);

        return $maxValue;
    }