当前位置: 首页>>代码示例>>PHP>>正文


PHP Cache::delete方法代码示例

本文整理汇总了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));
 }
开发者ID:intersvyaz,项目名称:yii2-cache-mutex,代码行数:10,代码来源:Mutex.php

示例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);
             });
         }
     }
 }
开发者ID:rmrevin,项目名称:yii2-rbac-command,代码行数:42,代码来源:Command.php

示例3: deleteAll

 /**
  * Deletes everything
  *
  * @return mixed
  */
 public function deleteAll()
 {
     $this->_db->createCommand()->delete($this->tableName);
     $this->_data = [];
     $this->_cache->delete($this->cacheKey);
 }
开发者ID:rocketyang,项目名称:hasscms-app,代码行数:11,代码来源:Config.php

示例4: deleteFromCache

 /**
  * @param int|string $userId
  * @param string $key
  * @return bool
  */
 protected function deleteFromCache($userId, $key)
 {
     return $this->cache->delete($this->buildCacheKey($userId, $key));
 }
开发者ID:cdcchen,项目名称:yii-plus,代码行数:9,代码来源:UserConfig.php

示例5: delete

 /**
  * @param mixed $key
  *
  * @return boolean
  *
  * @see yii\caching\Cache::delete()
  */
 public function delete($key)
 {
     return $this->cache->delete($key);
 }
开发者ID:iiifx-production,项目名称:yii2-lazy-cache,代码行数:11,代码来源:LazyCache.php

示例6: delete

 /**
  * Delete row by name
  * @param $name
  * @return mixed
  */
 public function delete($name)
 {
     return $this->_cache->delete($this->prefix . $name);
 }
开发者ID:beowulfenator,项目名称:yii2-dynamic-image,代码行数:9,代码来源:ImagePathMap.php

示例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 = [];
 }
开发者ID:olessavluk,项目名称:yii2-settings,代码行数:26,代码来源:SettingsComponent.php


注:本文中的yii\caching\Cache::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。