Ejemplo n.º 1
0
 /**
  * Returns a list of all affected hashes for a given set of tags.
  *
  * @param array $tags
  *
  * @return array
  */
 private function getHashes(array $tags)
 {
     $hashes = [];
     foreach ($tags as $tag) {
         $tag = $this->redis->prefix($tag);
         if (!$this->redis->exists($tag)) {
             continue;
         }
         $hashes = array_merge($hashes, $this->redis->smembers($tag));
     }
     return array_unique($hashes);
 }
Ejemplo n.º 2
0
 /**
  * Get a list of features
  * @return An arry containing a list of features for a project and user
  */
 public function features()
 {
     $features_list = $this->redis->smembers("{$this->_feature_namespace()}:features");
     $pipe = $this->redis->multi(Redis::PIPELINE);
     foreach ($features_list as $feature) {
         $pipe->hgetall("{$this->_feature_namespace()}:feature:{$feature}");
     }
     $feature_data = $pipe->exec();
     $features = [];
     foreach ($features_list as $key => $feature) {
         $features[$feature] = $feature_data[$key];
     }
     return $features;
 }
Ejemplo n.º 3
0
 public function testsmembers()
 {
     $this->redis->del('set');
     $this->redis->sAdd('set', 'val');
     $this->redis->sAdd('set', 'val2');
     $this->redis->sAdd('set', 'val3');
     $array = array('val', 'val2', 'val3');
     $smembers = $this->redis->smembers('set');
     sort($smembers);
     $this->assertEquals($array, $smembers);
     $sMembers = $this->redis->sMembers('set');
     sort($sMembers);
     $this->assertEquals($array, $sMembers);
     // test alias
 }
Ejemplo n.º 4
0
 public function surveys()
 {
     return Redis::smembers("User:{$this->id}:surveys");
 }
Ejemplo n.º 5
0
 /**
  * Get a list of features
  * @return An arry containing a list of features for a project and user
  */
 public function features()
 {
     return $this->redis->smembers("{$this->_feature_namespace()}:features");
 }
Ejemplo n.º 6
0
	protected function load($id){
		$data = Redis::hgetall("Repository::$id");
		
		foreach($data as $key => $val){
			if($key % 2 == 0){
				$this->$val = json_decode($data[$key + 1], true);
			}
		}
		
		$this->files = Redis::smembers("Repository.Source::$id");
		
		$this->id = $id;
	}
Ejemplo n.º 7
0
 /**
  * Get all types
  *
  * @return mixed
  */
 public function types()
 {
     return $this->client->smembers('q:job:types');
 }
Ejemplo n.º 8
0
 /**
  * Return a list of paused workers
  *
  * @since 0.0.1
  * @return  array   An array of paused workers' name
  */
 public function getPausedWorker()
 {
     return (array) $this->redis->smembers(self::$pausedWorkerKey);
 }
 /**
  * 获取所有管道(tube)名
  *
  * @return mixed
  */
 public function getAllTubesNames()
 {
     return $this->client->smembers($this->name . ':' . Job::TUBES_TAB);
 }
Ejemplo n.º 10
0
echo $redis->lset("list", 1, "new_value");
$data = $redis->lRange("list", 0, -1);
echo "<pre>";
print_r($data);
$bool = $redis->ltrim("list", 0, 5);
echo $redis->lrem("list", "5");
$bool = $redis->rpoplpush("srcKey", "dstKey");
// SET
for ($i = 0; $i < 10; $i++) {
    $redis->sadd("myset", $i + rand(10, 99));
}
$bool = $redis->srem("myset", 16);
echo (int) $bool;
$bool = $redis->sMove("myset", "myset1", 35);
echo $bool;
$data = $redis->smembers("myset");
$bool = $redis->sismember("myset", 555);
echo (int) $bool;
echo $redis->scard("myset");
$redis->sinterstore("output", "myset", "myset1");
$data = $redis->smembers("output");
echo "<pre>";
// sort
$data = $redis->sort("myset", array("sort" => "desc"));
echo "<pre>";
print_r($data);
for ($i = 0; $i < 10; $i++) {
    $redis->zadd("zset", $i + rand(10, 99), $i + rand(100, 999));
}
$data = $redis->zrange("zset", 0, 3, "withscores");
echo "<pre>";
Ejemplo n.º 11
0
描述:执行sInter命令并把结果储存到新建的变量中。
参数:
Key: dstkey, the key to store the diff into.
Keys: key1, key2… keyN. key1..keyN are intersected as in sInter.
返回值:成功返回,交集的个数,失败false
*/
$redis->delete('test');
$redis->sadd("test", "111");
$redis->sadd("test", "222");
$redis->sadd("test", "333");
$redis->sadd("test1", "111");
$redis->sadd("test1", "444");
var_dump($redis->sinterstore('new', "test", "test1"));
//结果:int(1)
var_dump($redis->smembers('new'));
//结果:array(1) { [0]=> string(3) "111" }
/**
sunion

描述:
返回一个所有指定键的并集
参数:
Keys: key1, key2, … , keyN
返回值:成功返回合并后的集,失败false
*/
$redis->delete('test');
$redis->sadd("test", "111");
$redis->sadd("test", "222");
$redis->sadd("test", "333");
$redis->sadd("test1", "111");