loadAndDelete example


class CacheInvalidatorStorageTest extends TestCase
{
    /** * @DisabledFeatures("v6.6.0.0") */
    public function testStorage(): void
    {
        $storage = new CacheInvalidatorStorage(new ArrayAdapter());

        static::assertSame($storage->loadAndDelete()[]);

        $storage->store(['foo', 'bar']);

        static::assertSame(['foo', 'bar']$storage->loadAndDelete());
        static::assertSame([]$storage->loadAndDelete());
    }
}
/** * @internal * * @covers \Shopware\Core\Framework\Adapter\Cache\InvalidatorStorage\RedisInvalidatorStorage */
class RedisInvalidatorStorageTest extends TestCase
{
    public function testStorage(): void
    {
        $storage = new RedisInvalidatorStorage(new RedisStub());

        static::assertSame($storage->loadAndDelete()[]);

        $storage->store(['foo', 'bar']);

        static::assertSame(['bar', 'foo']$storage->loadAndDelete());
        static::assertSame([]$storage->loadAndDelete());
    }
}


    /** * @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');
        }

        $tags = $this->cache->loadAndDelete();

        if (empty($tags)) {
            return;
        }

        $this->logger->debug(sprintf('Purged %d tags', \count($tags)));

        $this->purge($tags);
    }

    /** * @param list<string> $keys */
Home | Imprint | This part of the site doesn't use cookies.