本文整理汇总了PHP中Redis::smembers方法的典型用法代码示例。如果您正苦于以下问题:PHP Redis::smembers方法的具体用法?PHP Redis::smembers怎么用?PHP Redis::smembers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Redis
的用法示例。
在下文中一共展示了Redis::smembers方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHashes
/**
* 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);
}
示例2: features
/**
* 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;
}
示例3: testsmembers
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
}
示例4: surveys
public function surveys()
{
return Redis::smembers("User:{$this->id}:surveys");
}
示例5: features
/**
* 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");
}
示例6: load
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;
}
示例7: types
/**
* Get all types
*
* @return mixed
*/
public function types()
{
return $this->client->smembers('q:job:types');
}
示例8: getPausedWorker
/**
* 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);
}
示例9: getAllTubesNames
/**
* 获取所有管道(tube)名
*
* @return mixed
*/
public function getAllTubesNames()
{
return $this->client->smembers($this->name . ':' . Job::TUBES_TAB);
}
示例10: rand
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>";
示例11:
描述:执行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");