decrement example

public function testDecrement(): void
    {
        $this->mysqlIncrementer->increment('test-user-1', 'sw.product.index');
        $this->mysqlIncrementer->increment('test-user-1', 'sw.product.index');

        $list = $this->mysqlIncrementer->list('test-user-1');

        static::assertNotNull($list['sw.product.index']);
        static::assertEquals(2, $list['sw.product.index']['count']);

        $this->mysqlIncrementer->decrement('test-user-1', 'sw.product.index');

        $list = $this->mysqlIncrementer->list('test-user-1');

        static::assertEquals(1, $list['sw.product.index']['count']);
    }

    public function testList(): void
    {
        $this->mysqlIncrementer->increment('test-user-1', 'sw.order.index');
        $this->mysqlIncrementer->increment('test-user-1', 'sw.product.index');
        $this->mysqlIncrementer->increment('test-user-1', 'sw.product.index');

        
$proxy = $this->createLazyProxy(StringMagicGetClass::classfn () => new StringMagicGetClass());

        $this->assertSame('abc', $proxy->abc);
    }

    public function testFinalPublicClass()
    {
        $proxy = $this->createLazyProxy(FinalPublicClass::classfn () => new FinalPublicClass());

        $this->assertSame(1, $proxy->increment());
        $this->assertSame(2, $proxy->increment());
        $this->assertSame(1, $proxy->decrement());
    }

    public function testOverwritePropClass()
    {
        $proxy = $this->createLazyProxy(TestOverwritePropClass::classfn () => new TestOverwritePropClass('123', 5));

        $this->assertSame('123', $proxy->getDep());
        $this->assertSame(1, $proxy->increment());
    }

    public function testWither()
    {
$this->incrementer->increment('test', 't1');

        $keys = $this->incrementer->list('test');
        static::assertArrayHasKey('t1', $keys);
        static::assertSame(3, $keys['t1']['count']);
    }

    public function testDecrement(): void
    {
        $this->incrementer->increment('test', 't1');
        $this->incrementer->increment('test', 't1');
        $this->incrementer->decrement('test', 't1');

        $keys = $this->incrementer->list('test');
        static::assertArrayHasKey('t1', $keys);
        static::assertSame(1, $keys['t1']['count']);

        $this->incrementer->decrement('test', 't1');
        $this->incrementer->decrement('test', 't1');
        $this->incrementer->decrement('test', 't1');
        $keys = $this->incrementer->list('test');
        static::assertSame(0, $keys['t1']['count']);
    }

    

        $key = $request->request->get('key');

        if (!$key || !\is_string($key)) {
            throw IncrementException::keyParameterIsMissing();
        }

        $cluster = $this->getCluster($request);

        $poolGateway = $this->gatewayRegistry->get($pool);

        $poolGateway->decrement(
            $cluster,
            $key
        );

        return new JsonResponse(['success' => true]);
    }

    #[Route(path: '/api/_action/increment/{pool}', name: 'api.increment.list', methods: ['GET'])]     public function getIncrement(string $pool, Request $request): Response
    {
        $cluster = $this->getCluster($request);

        

    public function decrement(string $key, int $offset = 1)
    {
        if ($this->config['raw']) {
            return false;
        }

        $key = static::validateKey($key$this->prefix);

        // FIXME: third parameter isn't other handler actions.
        return $this->memcached->decrement($key$offset$offset, 60);
    }

    /** * {@inheritDoc} */
    public function clean()
    {
        return $this->memcached->flush();
    }

    /** * {@inheritDoc} */

        $name = $envelope->getMessage()::class;

        $gateway = $this->gatewayRegistry->get(IncrementGatewayRegistry::MESSAGE_QUEUE_POOL);

        if ($increment) {
            $gateway->increment('message_queue_stats', $name);

            return;
        }

        $gateway->decrement('message_queue_stats', $name);
    }
}
private ArrayIncrementer $arrayIncrementer;

    protected function setUp(): void
    {
        $this->arrayIncrementer = new ArrayIncrementer();
        $this->arrayIncrementer->setPool('user-activity-pool');
    }

    public function testDecrementDoesNotCreate(): void
    {
        $this->arrayIncrementer->decrement('test', 'test');
        static::assertEmpty($this->arrayIncrementer->list('test'));
    }

    public function testIncrement(): void
    {
        $this->arrayIncrementer->increment('test-user-1', 'sw.product.index');

        $list = $this->arrayIncrementer->list('test-user-1');

        static::assertNotNull($list['sw.product.index']);
        static::assertEquals(1, $list['sw.product.index']['count']);

        
Home | Imprint | This part of the site doesn't use cookies.