本文整理汇总了PHP中yii\caching\Cache::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::delete方法的具体用法?PHP Cache::delete怎么用?PHP Cache::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\caching\Cache
的用法示例。
在下文中一共展示了Cache::delete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: releaseLock
/**
* @inheritdoc
*/
protected function releaseLock($name)
{
if (!$this->cache instanceof Cache) {
return false;
}
return $this->cache->delete($this->getCacheKey($name));
}
示例2: restoreAssignments
/**
* @param array $assignments
* $assignments = [
* 'user_id' => ['role_1', 'role_2', 'role_3'],
* '1' => ['admin', 'user'],
* '2' => ['client', 'user'],
* '3' => ['manager', 'seller', 'support', 'user'],
* ];
* @throws \yii\base\InvalidConfigException
*/
protected function restoreAssignments($assignments)
{
$useCache = $this->useCache === true;
foreach ($assignments as $user_id => $items) {
if (!empty($this->forceAssign)) {
if (!is_array($this->forceAssign)) {
$this->forceAssign = (array) $this->forceAssign;
}
foreach ($this->forceAssign as $role) {
$this->authManager->assign(RbacFactory::Role($role), $user_id);
echo sprintf(' > role `%s` force assigned to user id: %s.', $role, $user_id) . PHP_EOL;
}
}
if (!empty($items)) {
foreach ($items as $item) {
$item = isset($this->assignmentsMap[$item]) ? $this->assignmentsMap[$item] : $item;
if (empty($item) || in_array($item, (array) $this->forceAssign, true)) {
continue;
}
$this->authManager->assign(RbacFactory::Role($item), $user_id);
echo sprintf(' > role `%s` assigned to user id: %s.', $item, $user_id) . PHP_EOL;
}
}
}
if ($useCache) {
if ($this->cache->exists('assignments-0')) {
$this->cacheIterator(function ($key) {
$this->cache->delete($key);
});
}
}
}
示例3: deleteAll
/**
* Deletes everything
*
* @return mixed
*/
public function deleteAll()
{
$this->_db->createCommand()->delete($this->tableName);
$this->_data = [];
$this->_cache->delete($this->cacheKey);
}
示例4: deleteFromCache
/**
* @param int|string $userId
* @param string $key
* @return bool
*/
protected function deleteFromCache($userId, $key)
{
return $this->cache->delete($this->buildCacheKey($userId, $key));
}
示例5: delete
/**
* @param mixed $key
*
* @return boolean
*
* @see yii\caching\Cache::delete()
*/
public function delete($key)
{
return $this->cache->delete($key);
}
示例6: delete
/**
* Delete row by name
* @param $name
* @return mixed
*/
public function delete($name)
{
return $this->_cache->delete($this->prefix . $name);
}
示例7: commit
protected function commit()
{
/* @fixme: implement batch operations */
foreach ($this->toRemove as $category => $keyvalue) {
foreach ($keyvalue as $key => $value) {
$this->db->createCommand()->delete($this->tableName, ['category' => $category, 'key' => $key])->execute();
}
}
foreach ($this->toSave as $category => $keyvalue) {
foreach ($keyvalue as $key => $value) {
$obj = (new Query())->from($this->tableName)->where(['category' => $category, 'key' => $key])->one($this->db);
$command = $this->db->createCommand();
if ($obj) {
$command = $command->update($this->tableName, ['value' => @serialize($value)], ['category' => $category, 'key' => $key]);
} else {
$command = $command->insert($this->tableName, ['category' => $category, 'key' => $key, 'value' => @serialize($value)]);
}
$command->execute();
}
}
if (count($this->toRemove) + count($this->toSave) > 0) {
$this->cache->delete('settings');
}
$this->toRemove = [];
$this->toSave = [];
}