Ejemplo n.º 1
0
 public function testClearQueue()
 {
     $time = time();
     $uTime = microtime(true);
     $queue = new UniqueQueue($this->redis, 'test', [UniqueQueue::OPT_DEL_MAX_CHUNK_SIZE => 2]);
     $this->redis->lpush('test', [1, 5, 3]);
     $this->redis->sadd('test-unique', [1, 5, 3]);
     $processingQueue1 = sprintf('test-processing-%s[%d][%d]', gethostname(), getmypid(), $time - 15);
     $this->redis->lpush($processingQueue1, [1, 8, 4]);
     $this->redis->hset('test-timeouts', $processingQueue1, $uTime - 15);
     $processingQueue2 = sprintf('test-processing-%s[%d][%d]', gethostname(), getmypid(), $time - 10);
     $this->redis->lpush($processingQueue2, [2, 6, 7]);
     $this->redis->hset('test-timeouts', $processingQueue2, $uTime - 10);
     $queue->clearQueue();
     $this->assertKeys([]);
 }
Ejemplo n.º 2
0
 public function testClearQueue()
 {
     $time = time();
     $uTime = microtime(true);
     $queue = new UniqueQueue($this->redis, 'test', [UniqueQueue::OPT_DEL_MAX_CHUNK_SIZE => 2, Base::OPT_SLAVES_SYNC_ENABLED => true, Base::OPT_SLAVES_SYNC_REQUIRED_COUNT => 5]);
     $this->redis->lpush('test', [1, 5, 3]);
     $this->redis->sadd('test-unique', [1, 5, 3]);
     $processingQueue1 = sprintf('test-processing-%s[%d][%d]', gethostname(), getmypid(), $time - 15);
     $this->redis->lpush($processingQueue1, [1, 8, 4]);
     $this->redis->hset('test-timeouts', $processingQueue1, $uTime - 15);
     $processingQueue2 = sprintf('test-processing-%s[%d][%d]', gethostname(), getmypid(), $time - 10);
     $this->redis->lpush($processingQueue2, [2, 6, 7]);
     $this->redis->hset('test-timeouts', $processingQueue2, $uTime - 10);
     try {
         $queue->clearQueue();
     } catch (\PhpRQ\Exception\NotEnoughSlavesSynced $e) {
     }
     $this->assertKeys([]);
 }
Ejemplo n.º 3
0
 public function testClearQueue()
 {
     $queue = new UniqueQueue($this->redis, 'test', [UniqueQueue::OPT_DEL_MAX_CHUNK_SIZE => 2], $this->getTimeMock());
     $this->redis->lpush('test', [1, 5, 3]);
     $this->redis->sadd('test-unique', [1, 5, 3]);
     $processingQueue1 = sprintf('test-processing-%s[%d][%d]', gethostname(), getmypid(), self::TIME_MOCK - 15);
     $this->redis->lpush($processingQueue1, [1, 8, 4]);
     $this->redis->hset('test-timeouts', $processingQueue1, self::MICRO_TIME_MOCK - 15);
     $processingQueue2 = sprintf('test-processing-%s[%d][%d]', gethostname(), getmypid(), self::TIME_MOCK - 10);
     $this->redis->lpush($processingQueue2, [2, 6, 7]);
     $this->redis->hset('test-timeouts', $processingQueue2, self::MICRO_TIME_MOCK - 10);
     $queue->clearQueue();
     $this->assertKeys([]);
 }