コード例 #1
0
ファイル: PredisAdapter.php プロジェクト: genkgo/cache
 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);
 }
コード例 #2
0
ファイル: PredisEngine.php プロジェクト: renan/cakephp-predis
 /**
  * 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;
 }
コード例 #3
0
ファイル: PredisTest.php プロジェクト: gmo/cache
 /**
  * @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('*'));
 }
コード例 #4
0
ファイル: Service.php プロジェクト: spryker/Storage
 /**
  * @return int
  */
 public function getCountItems()
 {
     return count($this->client->keys($this->getSearchPattern()));
 }