Пример #1
0
 /**
  * Remove dead process pids from redis set.
  *
  * @param  \ARedisSet $pool
  * @return integer    amount of dead pids
  */
 protected function checkPidPool(\ARedisSet $pool)
 {
     $removed = 0;
     $pids = $pool->getData(true);
     foreach ($pids as $pid) {
         if ($this->isPidAlive($pid)) {
             continue;
         }
         $pool->remove($pid);
         $removed++;
     }
     return $removed;
 }
Пример #2
0
 public function testMove()
 {
     $redis = $this->getConnection();
     $set1 = new ARedisSet("TestSet1:" . uniqid(), $redis);
     $set2 = new ARedisSet("TestSet2:" . uniqid(), $redis);
     $this->assertTrue($set1->add("1"));
     $this->assertTrue($set2->add("1"));
     $this->assertTrue($set1->add("5"));
     $this->assertTrue($set1->add("10"));
     $this->assertTrue($set1->move($set2, "1"));
     $this->assertFalse($set1->move($set2, "1"));
     $this->assertTrue($set1->move($set2, "5"));
     $this->assertTrue($set1->move($set2, "10"));
     $this->assertEquals(0, $set1->getCount());
     $this->assertEquals(3, $set2->getCount());
     $set1->clear();
     $set2->clear();
 }