Exemplo n.º 1
0
 public function testAddItem()
 {
     $queue = new UniqueQueue($this->redis, 'test');
     $queue->addItem(1);
     $queue->addItem(3);
     $queue->addItem(5);
     $queue->addItem(3);
     $this->assertSame(['5', '3', '1'], $this->redis->lrange('test', 0, 5));
     $items = $this->redis->smembers('test-unique');
     $this->assertCount(3, $items);
     $this->assertTrue(in_array('1', $items, true));
     $this->assertTrue(in_array('3', $items, true));
     $this->assertTrue(in_array('5', $items, true));
     $this->assertKeys(['test', 'test-unique']);
 }
Exemplo n.º 2
0
 public function testAddItem()
 {
     $queue = new UniqueQueue($this->redis, 'test', [Base::OPT_SLAVES_SYNC_ENABLED => true, Base::OPT_SLAVES_SYNC_REQUIRED_COUNT => 5]);
     try {
         $queue->addItem(1);
     } catch (\PhpRQ\Exception\NotEnoughSlavesSynced $e) {
     }
     $this->assertSame(['1'], $this->redis->lrange('test', 0, 5));
     $this->assertSame(['1'], $this->redis->smembers('test-unique'));
     $this->assertKeys(['test', 'test-unique']);
 }