Validate if a string is a valid cache.

@param string $cache The cache name

@return mixed The cache name if valid or FALSE if not valid
199804
public function isValidCache($cache)
    {
        // Get the valid caches
        $caches = $this->getCaches();
        $cacheKeys = array_keys($caches);
        $cacheKeys[] = 'all';

        if (!in_array($cache, array_values($cacheKeys))) {
            return false;
        }

        return $cache;
    }
76220
public function has($key)
	{
		return $this->engine->get($this->id($key)) !== false || $this->engine->getResultCode() != \Memcached::RES_NOTFOUND;
	}
310474
protected function validateItemCache($data)
    {
        if (!$data || !is_array($data)) {
            return false;
        }
        foreach (['classes', 'interfaces', 'traits'] as $key) {
            // Must be set
            if (!isset($data[$key])) {
                return false;
            }
            // and an array
            if (!is_array($data[$key])) {
                return false;
            }
            // Detect legacy cache keys (non-associative)
            $array = $data[$key];
            if (!empty($array) && is_numeric(key($array))) {
                return false;
            }
        }
        return true;
    }
1116884
public function validate() {        
        if($this instanceof Cache\CacheableValidatableInterface && $this->isValidationCacheEnabled() && $this->lastValidationResult instanceof ValidationResultSet) {
            return $this->lastValidationResult;
        }
        
        $validationResultSet = $this->validateValue($this->getValue());
        
        if($this instanceof Cache\CacheableValidatableInterface && $this->isValidationCacheEnabled()) {
            $this->lastValidationResult = $validationResultSet;
        }
            
        return $validationResultSet;
    }
1309227
protected function validCache($value)
    {
        if (is_null($value) || !is_array($value) || empty($value)) {
            return false;
        }

        return true;
    }
1078004
protected function validateKey(/*# string */ &$key)
    {
        // validate key
        if (is_string($key)) {
            $key = trim($key);
            return;
        }

        // throw exception
        throw new InvalidArgumentException(
            Message::get(Message::CACHE_INVALID_KEY, $key),
            Message::CACHE_INVALID_KEY
        );
    }
344273
public function get($cache = null)
    {
        if (is_null($cache)) {
            $cache = $this->getDefaultCache();
        }

        if ($cache instanceof CacheItemPoolInterface) {
            return $cache;
        }
        if ($cache instanceof CacheInterface) {
            return $cache;
        }

        foreach ($this->callbacks as $callBack) {
            $result = call_user_func($callBack, $cache);
            if ($result instanceof CacheItemPoolInterface) {
                return $result;
            }
            if ($result instanceof CacheInterface) {
                return $result;
            }
        }

        throw new InvalidArgumentException(Message::INVALID_CACHE_ADAPTER);
    }
972285
public function get($key)
    {
        if (!$this->requireProvider("Getting key " . $key)) return false;

        return $this->cacheProvider->get($key);
    }
1331864
public static function isValidCode($code)
    {
        if (array_key_exists($code, self::getInfoForCurrencies())) {
            return true;
        } elseif (array_key_exists($code, self::getInfoForCurrenciesWithoutCurrencyCode())) {
            return true;
        } elseif (array_key_exists($code, self::getInfoForCurrenciesWithUnofficialCode())) {
            return true;
        } elseif (array_key_exists($code, self::getInfoForCurrenciesWithHistoricalCode())) {
            return true;
        } else {
            return false;
        }
    }
58952
public function delete($key)
    {
        /* If $key is not valid string throws InvalidArgumentException */
        if (!$this->isString($key)) {
            throw new InvalidArgumentException('Cache key must be not empty string');
        }

        $path = sha1($key);

        if ($this->filesystem()->has($path)) {
            $this->filesystem()->delete($path);
            return true;
        }
        return false;
    }
1333476
function has_valid( $key, $expiration = null ) {
            $cache_entry = $this->_options->get_option( $key, false );

            $is_valid = ( is_object( $cache_entry ) &&
                          isset( $cache_entry->timestamp ) &&
                          is_numeric( $cache_entry->timestamp ) &&
                          $cache_entry->timestamp > WP_FS__SCRIPT_START_TIME
            );

            if ( $is_valid &&
                 is_numeric( $expiration ) &&
                 isset( $cache_entry->created ) &&
                 is_numeric( $cache_entry->created ) &&
                 $cache_entry->created + $expiration < WP_FS__SCRIPT_START_TIME
            ) {
                /**
                 * Even if the cache is still valid, since we are checking for validity
                 * with an explicit expiration period, if the period has past, return
                 * `false` as if the cache is invalid.
                 *
                 * @since 1.2.2.7
                 */
                $is_valid = false;
            }

            return $is_valid;
        }
9117
public function has($key)
    {
        /* If $key is not valid string throws InvalidArgumentException */
        if (!$this->isString($key)) {
            throw new InvalidArgumentException('Cache key must be not empty string');
        }

        return $this->getCollection()->has($key);
    }
241270
public function useCache($caching = null)
    {
        if (is_null($caching)) {
            return ($this->useCache && $this->getCache());
        }

        $this->useCache = (bool) $caching;

        return $this;
    }
305664
public static function validateCache($file, $cacheTTL, $cacheForever)
    {
        $currentTime = time();
        $expireTime  = $cacheTTL * 60 * 60;
        $fileTime    = filemtime($file);
        return ($currentTime - $expireTime < $fileTime)
                or $cacheForever;
    }
892762
public static function validateKey($key)
    {
        if (!\is_string($key)) {
            throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given', \is_object($key) ? \get_class($key) : \gettype($key)));
        }
        if ('' === $key) {
            throw new InvalidArgumentException('Cache key length must be greater than zero');
        }
        if (false !== strpbrk($key, '{}()/\@:')) {
            throw new InvalidArgumentException(sprintf('Cache key "%s" contains reserved characters {}()/\@:', $key));
        }

        return $key;
    }
100878
public static function isValidEmail($email)
    {
        /*
         * Not a string?
         * Nothing to do
         */
        if (!is_string($email)) {
            return false;
        }

        $pattern = self::getEmailPattern();

        return (bool)preg_match($pattern, $email);
    }
225299
protected function validateKey($key)
    {
        if (!is_string($key)) {
            throw new CacheKeyException("Cache key must be a string, " . gettype($key) . " given");
        }

        if (preg_match("/[^A-Za-z0-9\._-]/", $key)) {
            throw new CacheKeyException("Cache key contains invalid characters: {$key}");
        }

        if (strlen($key) > 64) {
            throw new CacheKeyException("Cache key cannot be longer than 64 characters: {$key}");
        }
    }