예제 #1
0
 /**
  * @dataProvider dataProviderTestedClients
  */
 public function testRemoveTemp($redisClient)
 {
     $keys_chunk = array_chunk($redisClient->keys($this->getPrefixKey() . '*'), 100);
     foreach ($keys_chunk as $keys) {
         $redisClient->del($keys);
     }
     $this->array($redisClient->keys($this->getPrefixKey() . '*'))->isEmpty();
     $bitter = new TestedBitter($redisClient, $this->getPrefixKey(), $this->getPrefixTempKey());
     $yesterday = new Day('drink_a_bitter_beer', new DateTime('yesterday'));
     $today = new Day('drink_a_bitter_beer', new DateTime('today'));
     $bitter->mark('drink_a_bitter_beer', 13, new DateTime('today'));
     $bitter->mark('drink_a_bitter_beer', 13, new DateTime('yesterday'));
     $bitter->mark('drink_a_bitter_beer', 404, new DateTime('yesterday'));
     $bitter->bitOpOr('test_b', $today, $yesterday);
     $this->array($redisClient->keys($this->getPrefixKey() . '*'))->isNotEmpty();
     $this->array($redisClient->keys($this->getPrefixTempKey() . '*'))->isNotEmpty();
     $this->object($bitter->removeTemp())->isIdenticalTo($bitter);
     $this->array($redisClient->keys($this->getPrefixTempKey() . '*'))->strictlyContains($this->getPrefixTempKey() . 'keys');
     $this->array($redisClient->keys($this->getPrefixKey() . '*'))->isNotEmpty();
     // Expire timeout
     $this->removeAll($redisClient);
     $bitter = new TestedBitter($redisClient, $this->getPrefixKey(), $this->getPrefixTempKey(), 2);
     $bitter->mark('drink_a_bitter_beer', 13, new DateTime('today'));
     $bitter->mark('drink_a_bitter_beer', 13, new DateTime('yesterday'));
     $bitter->mark('drink_a_bitter_beer', 404, new DateTime('yesterday'));
     $bitter->bitOpOr('test_b', $today, $yesterday);
     $this->array($redisClient->keys($this->getPrefixTempKey() . '*'))->isNotEmpty();
     sleep(3);
     $this->array($redisClient->keys($this->getPrefixTempKey() . '*'))->strictlyContains($this->getPrefixTempKey() . 'keys');
     $this->removeAll($redisClient);
 }
예제 #2
0
 public function __construct($redisClient, $prefixKey, $expireTimeout)
 {
     parent::__construct($redisClient, $prefixKey . ':', $prefixKey . '_temp:', $expireTimeout);
 }