src/Adapter/MemoryCacheItemPool.php
public function hasItem($key)
    {
        if (isset($this->data[$key])) {
            
            /* @var $item \Psr6NullCache\CacheItem */
            $item = $this->data[$key];
            
            if ($item->isHit() === true && ($item->getExpires() === null || $item->getExpires() > new DateTime())) {
                return true;
            }
        }
        
        return false;
    }
public function hasItem($key)
    {
        if (isset($this->data[$key])) {
            
            /* @var $item \Psr6NullCache\CacheItem */
            $item = $this->data[$key];
            
            if ($item->isHit() === true && ($item->getExpires() === null || $item->getExpires() > new DateTime())) {
                return true;
            }
        }
        
        return false;
    }
Confirms if the cache contains specified cache item.

Note: This method MAY avoid retrieving the cached value for performance reasons.
This could result in a race condition with CacheItemInterface::get(). To avoid
such situation use CacheItemInterface::isHit() instead.

@param string $key
The key for which to check existence.

@throws InvalidArgumentException If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException
MUST be thrown.

@return bool True if item exists in the cache, false otherwise.