本文整理匯總了PHP中Predis\Client::sAdd方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::sAdd方法的具體用法?PHP Client::sAdd怎麽用?PHP Client::sAdd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Predis\Client
的用法示例。
在下文中一共展示了Client::sAdd方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addToIndex
protected function addToIndex($key, $expires = null)
{
if ($this->indexing) {
$this->store->sAdd("{$this->prefix}::index", $key);
}
return parent::addToIndex($key, $expires);
}
示例2: setAccess
/**
* @param $roleName
* @param $resourceName
* @param $accessName
* @param $action
* @return bool
* @throws Exception
*/
protected function setAccess($roleName, $resourceName, $accessName, $action)
{
/**
* Check if the access is valid in the resource
*/
if ($this->isResourceAccess($resourceName, $accessName)) {
if (!$this->setNXAccess) {
throw new Exception("Access '" . $accessName . "' does not exist in resource '" . $resourceName . "' in ACL");
}
$this->addResourceAccess($resourceName, $accessName);
}
$this->redis->sAdd("accessList:{$roleName}:{$resourceName}:{$action}", $accessName);
$accessList = "accessList:{$roleName}:{$resourceName}";
// remove first if exists
foreach (array(1, 2) as $act) {
$this->redis->sRem("{$accessList}:{$act}", $accessName);
$this->redis->sRem("{$accessList}:{$act}", "*");
}
$this->redis->sAdd("{$accessList}:{$action}", $accessName);
$this->redis->sAdd("{$accessList}:{$this->getDefaultAction()}", "*");
return true;
}
示例3: addItemList
/**
* Adds a values to the set value stored at key.
* If this value is already in the set, FALSE is returned.
*
* @param $key
* @param $value
* @return boolean
*/
public function addItemList($key, $value)
{
return $this->client->sAdd($key, $value);
}