purge example


    public function clearAll(Smarty $smarty$exp_time=null)
    {
        if (!$this->purge()) {
            $this->invalidate(null);
        }
        return -1;
    }

    /** * Empty cache for a specific template * * {@internal the $exp_time argument is ignored altogether}} * * @param Smarty $smarty Smarty object * @param string $resource_name template name * @param string $cache_id cache id * @param string $compile_id compile id * @param integer $exp_time expiration time [being ignored] * @return integer number of cache files deleted [always -1] * @uses buildCachedFilepath() to generate the CacheID * @uses invalidate() to mark CacheIDs parent chain as outdated * @uses delete() to remove CacheID from cache */
self::assertTrue($profiler->isEnabled());
    }

    protected function setUp(): void
    {
        $this->tmp = tempnam(sys_get_temp_dir(), 'sf_profiler');
        if (file_exists($this->tmp)) {
            @unlink($this->tmp);
        }

        $this->storage = new FileProfilerStorage('file:'.$this->tmp);
        $this->storage->purge();
    }

    protected function tearDown(): void
    {
        if (null !== $this->storage) {
            $this->storage->purge();
            $this->storage = null;

            @unlink($this->tmp);
        }
    }
}
static::assertTrue($response->headers->has(CacheResponseSubscriber::INVALIDATION_STATES_HEADER));
        static::assertSame($response->headers->get(CacheResponseSubscriber::INVALIDATION_STATES_HEADER), CacheResponseSubscriber::STATE_LOGGED_IN);
    }

    public function testPurge(): void
    {
        $gateway = $this->createMock(AbstractReverseProxyGateway::class);
        $gateway->expects(static::once())->method('ban')->with(['/foo']);
        $store = new ReverseProxyCache($gateway$this->createMock(CacheTracer::class)[]);

        $store->purge('/foo');
    }

    public function testInvalidateWithoutOriginalUrl(): void
    {
        $gateway = $this->createMock(AbstractReverseProxyGateway::class);
        $gateway->expects(static::never())->method('ban');
        $store = new ReverseProxyCache($gateway$this->createMock(CacheTracer::class)[]);
        $store->invalidate(new Request());
    }

    public function testTaggingOfRequest(): void
    {
$this->assertFalse($this->store->unlock($this->request));
    }

    public function testRemovesEntriesForKeyWithPurge()
    {
        $request = Request::create('/foo');
        $this->store->write($requestnew Response('foo'));

        $metadata = $this->getStoreMetadata($request);
        $this->assertNotEmpty($metadata);

        $this->assertTrue($this->store->purge('/foo'));
        $this->assertEmpty($this->getStoreMetadata($request));

        // cached content should be kept after purging         $path = $this->store->getPath($metadata[0][1]['x-content-digest'][0]);
        $this->assertTrue(is_file($path));

        $this->assertFalse($this->store->purge('/bar'));
    }

    public function testStoresACacheEntry()
    {
        
return $ret;
    }

    /** * Purges all data from the storage. * * @return void */
    public function purge()
    {
        $this->storage->purge();
    }

    /** * Finds profiler tokens for the given criteria. * * @param int|null $limit The maximum number of tokens to return * @param string|null $start The start date to search from * @param string|null $end The end date to search to * * @see https://php.net/datetime.formats for the supported date/time formats */
    

    private string $tmpDir;
    private FileProfilerStorage $storage;

    protected function setUp(): void
    {
        $this->tmpDir = sys_get_temp_dir().'/sf_profiler_file_storage';
        if (is_dir($this->tmpDir)) {
            self::cleanDir();
        }
        $this->storage = new FileProfilerStorage('file:'.$this->tmpDir);
        $this->storage->purge();
    }

    protected function tearDown(): void
    {
        self::cleanDir();
    }

    public function testStore()
    {
        for ($i = 0; $i < 10; ++$i) {
            $profile = new Profile('token_'.$i);
            
if (empty($tags)) {
            return;
        }

        if ($this->delay > 0 && !$force) {
            $this->cache->store($tags);

            return;
        }

        $this->purge($tags);
    }

    /** * @deprecated tag:v6.6.0 - The parameter $time is obsolete and will be removed in v6.6.0.0 */
    public function invalidateExpired(?\DateTime $time = null): void
    {
        if ($time) {
            Feature::triggerDeprecationOrThrow('v6.6.0.0', 'The parameter $time in \Shopware\Core\Framework\Adapter\Cache\CacheInvalidator::invalidateExpired is obsolete and will be removed in v6.6.0.0');
        }

        
return $ret;
    }

    /** * Purges all data from the storage. * * @return void */
    public function purge()
    {
        $this->storage->purge();
    }

    /** * Finds profiler tokens for the given criteria. * * @param int|null $limit The maximum number of tokens to return * @param string|null $start The start date to search from * @param string|null $end The end date to search to * * @see https://php.net/datetime.formats for the supported date/time formats */
    

    }

    private function getDefaultPublishRoutingKey(): ?string
    {
        return $this->exchangeOptions['default_publish_routing_key'] ?? null;
    }

    public function purgeQueues(): void
    {
        foreach ($this->getQueueNames() as $queueName) {
            $this->queue($queueName)->purge();
        }
    }

    private function getRoutingKeyForMessage(?AmqpStamp $amqpStamp): ?string
    {
        return $amqpStamp?->getRoutingKey() ?? $this->getDefaultPublishRoutingKey();
    }
}
$result = $this->getStore()->purgeByHeader('x-shopware-cache-id', $cacheId);
            } else {
                $result = $this->getStore()->purgeAll();
            }

            if ($result) {
                $response->setStatusCode(Response::HTTP_OK, 'Banned');
            } else {
                $response->setStatusCode(Response::HTTP_OK, 'Not Banned');
            }
        } elseif ($request->getMethod() === 'PURGE') {
            if ($this->getStore()->purge($request->getUri())) {
                $response->setStatusCode(Response::HTTP_OK, 'Purged');
            } else {
                $response->setStatusCode(Response::HTTP_OK, 'Not purged');
            }
        }

        return $response;
    }

    /** * Lookups a Response from the cache for the given Request. * * {@inheritdoc} * * @param bool $catch * * @return Response */
Home | Imprint | This part of the site doesn't use cookies.