Exemplo n.º 1
0
 private function deleteGlob($pattern)
 {
     $keys = $this->client->keys($pattern);
     $options = $this->client->getOptions();
     if (isset($options->prefix)) {
         $length = strlen($options->prefix->getPrefix());
         $keys = array_map(function ($key) use($length) {
             return substr($key, $length);
         }, $keys);
     }
     if (count($keys) === 0) {
         return;
     }
     $this->client->del($keys);
 }
Exemplo n.º 2
0
 /**
  * Delete all keys from the cache
  *
  * @param bool $check if true will check expiration, otherwise delete all
  * @return bool True if the cache was successfully cleared, false otherwise
  */
 public function clear($check)
 {
     if ($check) {
         return true;
     }
     $keys = $this->client->keys($this->_config['prefix'] . '*');
     foreach ($keys as $key) {
         $this->client->del($key);
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * @group redis-keys
  */
 public function testKeys()
 {
     //$this->assertEquals(array(), $this->client->keys('derp'));
     $items = array('hello' => 1, 'hallo' => 1, 'hxllo' => 1, 'hllo' => 1, 'heeeello' => 1, 'hillo' => 1, 'hbllo' => 1, 'color:red' => 'red', 'color:blue' => 'blue', 'color:green' => 'green', '[ns]foo' => 'bar');
     $this->client->mset($items);
     $this->assertArraySimilar(array('hello', 'hallo', 'hxllo', 'hbllo', 'hillo'), $this->client->keys('h?llo'));
     $this->assertArraySimilar(array('hllo', 'hello', 'hallo', 'hxllo', 'hillo', 'hbllo', 'heeeello'), $this->client->keys('h*llo'));
     $this->assertArraySimilar(array('hello', 'hallo'), $this->client->keys('h[ae]llo'));
     $this->assertArraySimilar(array('hallo', 'hillo', 'hbllo', 'hxllo'), $this->client->keys('h[^e]llo'));
     $this->assertArraySimilar(array('hallo', 'hbllo'), $this->client->keys('h[a-b]llo'));
     $this->assertArraySimilar(array('color:green'), $this->client->keys('*en'));
     $this->assertArraySimilar(array('[ns]foo'), $this->client->keys('\\[ns\\]*'));
     $this->assertArraySimilar(array('color:red'), $this->client->keys('color:red'));
     $this->assertArraySimilar(array_keys($items), $this->client->keys('*'));
 }
Exemplo n.º 4
0
 /**
  * @return int
  */
 public function getCountItems()
 {
     return count($this->client->keys($this->getSearchPattern()));
 }