本文整理汇总了PHP中Predis\Client::sMembers方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::sMembers方法的具体用法?PHP Client::sMembers怎么用?PHP Client::sMembers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Predis\Client
的用法示例。
在下文中一共展示了Client::sMembers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: refreshIndex
/**
* Refresh the local cache index from the cache.
* The index is stored in Redis as a set with the key <prefix>::index.
* Items are added and removed from the index via the write and delete but
* are also expired automatically by Redis. This function reads the index
* set and checks the TTL of each key, removing those that no longer exist
* from the index.
* @return self
*/
public function refreshIndex()
{
if ($this->indexing) {
$expired = array();
foreach ($this->store->sMembers("{$this->prefix}::index") as $k) {
switch ($this->index[$k] = $this->store->ttl($k)) {
case -2:
$expired[] = $k;
unset($this->index[$k]);
break;
case -1:
// We're not running Redis 2.8 yet so we always get -1
// we'll assume all keys have an expiry and remove any without in order to keep the index clean
//$this->index[$k] = 2147483648;
$expired[] = $k;
unset($this->index[$k]);
break;
default:
$this->index[$k] = time() + $this->index[$k];
}
}
foreach ($expired as $k) {
$this->removeFromIndex($k);
}
}
return $this;
}
示例2: isAllowed
/**
* {@inheritdoc}
* Example:
* <code>
* //Does Andres have access to the customers resource to create?
* $acl->isAllowed('Andres', 'Products', 'create');
* //Do guests have access to any resource to edit?
* $acl->isAllowed('guests', '*', 'edit');
* </code>
*
* @param string $role
* @param string $resource
* @param string $access
*
* @return bool
*/
public function isAllowed($role, $resource, $access)
{
if ($this->redis->sIsMember("accessList:{$role}:{$resource}:" . Acl::ALLOW, $access)) {
return Acl::ALLOW;
}
if ($this->redis->exists("rolesInherits:{$role}")) {
$rolesInherits = $this->redis->sMembers("rolesInherits:{$role}");
foreach ($rolesInherits as $role) {
if ($this->redis->sIsMember("accessList:{$role}:{$resource}:" . Acl::ALLOW, $access)) {
return Acl::ALLOW;
}
}
}
/**
* Return the default access action
*/
return $this->getDefaultAction();
}
示例3: getListItems
/**
* @param $key
* @return mixed
*/
public function getListItems($key)
{
return $this->client->sMembers($key);
}