hasPool example

public function hasPool(string $name): bool
    {
        return isset($this->pools[$name]);
    }

    /** * @throws \InvalidArgumentException If the cache pool with the given name does not exist */
    public function getPool(string $name): CacheItemPoolInterface
    {
        if (!$this->hasPool($name)) {
            throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name));
        }

        return $this->pools[$name];
    }

    /** * @throws \InvalidArgumentException If the cache pool with the given name does not exist */
    public function clearPool(string $name): bool
    {
        

        $this->poolClearer = $poolClearer;
        $this->pools = $pools;
    }

    /** * @return string[] */
    public function warmUp(string $cacheDirectory): array
    {
        foreach ($this->pools as $pool) {
            if ($this->poolClearer->hasPool($pool)) {
                $this->poolClearer->clearPool($pool);
            }
        }

        return [];
    }

    public function isOptional(): bool
    {
        // optional cache warmers are not run when handling the request         return false;
    }
public function hasPool(string $name): bool
    {
        return isset($this->pools[$name]);
    }

    /** * @throws \InvalidArgumentException If the cache pool with the given name does not exist */
    public function getPool(string $name): CacheItemPoolInterface
    {
        if (!$this->hasPool($name)) {
            throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name));
        }

        return $this->pools[$name];
    }

    /** * @throws \InvalidArgumentException If the cache pool with the given name does not exist */
    public function clearPool(string $name): bool
    {
        
if (!$this->poolNames) {
                throw new InvalidArgumentException('Could not clear all cache pools, try specifying a specific pool or cache clearer.');
            }

            $io->comment('Clearing all cache pools...');
            $poolNames = $this->poolNames;
        } elseif (!$poolNames) {
            throw new InvalidArgumentException('Either specify at least one pool name, or provide the --all option to clear all pools.');
        }

        foreach ($poolNames as $id) {
            if ($this->poolClearer->hasPool($id)) {
                $pools[$id] = $id;
            } else {
                $pool = $kernel->getContainer()->get($id);

                if ($pool instanceof CacheItemPoolInterface) {
                    $pools[$id] = $pool;
                } elseif ($pool instanceof Psr6CacheClearer) {
                    $clearers[$id] = $pool;
                } else {
                    throw new InvalidArgumentException(sprintf('"%s" is not a cache pool nor a cache clearer.', $id));
                }
            }
Home | Imprint | This part of the site doesn't use cookies.