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


PHP Cache::remove方法代码示例

本文整理汇总了PHP中Nette\Caching\Cache::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::remove方法的具体用法?PHP Cache::remove怎么用?PHP Cache::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Caching\Cache的用法示例。


在下文中一共展示了Cache::remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFileLastCommit

 /**
  * Returns file last commit infos
  *
  * @param string $fileName
  * @param bool   $useCache
  * @return mixed
  * @throws gitHubException
  */
 public function getFileLastCommit($fileName, $useCache = TRUE)
 {
     if (!$useCache) {
         $this->cache->remove($fileName);
     }
     return $this->cache->load($fileName, function () use($fileName) {
         $path = $this->subdir ? $this->subdir . '/' : '';
         $url = self::GITHUB_URL . '/' . $this->user . '/' . $this->repo . '/commits?path=' . $path . $fileName;
         $tree = $this->run($url);
         return count($tree) === 0 ? NULL : $tree[0];
     });
 }
开发者ID:premekkoch,项目名称:github-service,代码行数:20,代码来源:GitHubService.php

示例2: remove

 /**
  * @param User $user
  * @throws ForeignKeyConstraintViolationException
  */
 public function remove(User $user)
 {
     try {
         $this->cache->remove($user);
         // will be recreated if an error occur
         $userID = $user->getId();
         $this->em->remove($user);
         $this->em->flush();
         $this->onSuccessUserRemoval($user, $userID);
     } catch (ForeignKeyConstraintViolationException $e) {
         // todo log
         throw $e;
     }
 }
开发者ID:blitzik,项目名称:CMS,代码行数:18,代码来源:UserRemover.php

示例3: update

 /**
  * @param array $values
  * @param User|null $user
  * @return ValidationObject
  */
 public function update(array $values, User $user)
 {
     $this->em->beginTransaction();
     $user->setFirstName($values['first_name']);
     $user->setLastName($values['last_name']);
     $validationObject = new ValidationObject();
     // todo could be optimized
     $user->clearRoles();
     $role = $this->getRole($values['role'], $validationObject);
     if (!$validationObject->isValid()) {
         $this->em->rollback();
         return $validationObject;
     }
     $user->addRole($role);
     $this->em->persist($user);
     $this->em->flush();
     if ($validationObject->isValid()) {
         $this->em->commit();
         $this->onSuccessUserEditing($user);
         $this->cache->remove($user->getCacheKey());
     } else {
         $this->em->rollback();
     }
     return $validationObject;
 }
开发者ID:blitzik,项目名称:CMS,代码行数:30,代码来源:UserPersister.php

示例4: processMessage

 /**
  * Process all messages.
  */
 private function processMessage()
 {
     if ($this->processed) {
         return;
     }
     $this->processed = TRUE;
     $files = glob($this->fileMailer->getTempDirectory() . DIRECTORY_SEPARATOR . '*.' . FileMailer::FILE_EXTENSION);
     foreach ($files as $path) {
         $cacheKey = basename($path);
         if ($this->removeExpired($path)) {
             $this->cache->remove($cacheKey);
             continue;
         }
         $message = $this->cache->load($cacheKey);
         if ($message === NULL) {
             $message = FileMailer::mailParser(file_get_contents($path), $cacheKey);
             $this->cache->save($cacheKey, $message);
         }
         $time = new DateTime();
         if ($message->date > $time->modify($this->newMessageTime)) {
             $this->countNew++;
         } else {
             $message->isOld = TRUE;
         }
         $this->countAll++;
         $this->messages[] = $message;
     }
     usort($this->messages, function ($a1, $a2) {
         return $a2->date->getTimestamp() - $a1->date->getTimestamp();
     });
 }
开发者ID:newPOPE,项目名称:FileMailer,代码行数:34,代码来源:MailPanel.php

示例5: cleanParametersCache

 /**
  * @return void
  */
 public function cleanParametersCache()
 {
     $this->parameters = NULL;
     if ($this->cache) {
         $this->cache->remove(self::PARAMETER_KEY);
     }
 }
开发者ID:webchemistry,项目名称:parameters,代码行数:10,代码来源:Provider.php

示例6: save

 public function save(array $values)
 {
     $options = $this->prepareOptions($this->findOptions());
     foreach ((array) $values as $key => $value) {
         $options[$key]->setValue($value == '' ? null : $value);
         $this->em->persist($options[$key]);
     }
     try {
         $this->em->flush();
         $this->cache->remove(Option::getCacheKey());
         $this->onSuccessOptionsSaving();
     } catch (\Exception $e) {
         $this->em->rollback();
         $this->em->close();
         $this->logger->addError(sprintf('Save Options error: %s | error message: %s', date('Y-m-d H:i:s'), $e->getMessage()));
         throw $e;
     }
 }
开发者ID:blitzik,项目名称:CMS,代码行数:18,代码来源:OptionsPersister.php

示例7: getDomains

 private function getDomains() : array
 {
     $this->repository->onAfterInsert[] = function () {
         $this->cache->remove(NULL);
     };
     return $this->cache->load(NULL, function (&$dependencies) {
         $dependencies[Nette\Caching\Cache::TAGS] = [];
         return array_map(function (Ytnuk\Web\Domain\Entity $entity) use($dependencies) {
             $dependencies[Nette\Caching\Cache::TAGS] = array_merge($dependencies[Nette\Caching\Cache::TAGS], $entity->getCacheTags());
             return $entity->id;
         }, iterator_to_array($this->repository->findAll()));
     });
 }
开发者ID:ytnuk,项目名称:web,代码行数:13,代码来源:Factory.php

示例8: invalidateByQuery

 /**
  * Invalidates according graph Uri entries, the result and all triple pattern.
  *
  * @param Query $queryObject All data according to this query will be invalidated.
  */
 public function invalidateByQuery(Query $queryObject)
 {
     // log it
     $this->addToLog(array('method' => 'invalidateByQuery', 'parameter' => array('queryObject' => $queryObject)));
     $query = $queryObject->getQuery();
     // load query cache container by given query
     $queryCacheContainer = $this->cache->load($query);
     /**
      * remove according query from the query list which belongs to one of the graph URI's in the query
      * cache container.
      */
     if (true === is_array($queryCacheContainer['graph_uris'])) {
         foreach ($queryCacheContainer['graph_uris'] as $graphUri) {
             $queryList = $this->cache->load($graphUri);
             unset($queryList[$query]);
             // if graphUri entry is empty after the operation, remove it from the cache
             if (0 == count($queryList)) {
                 $this->cache->remove($graphUri);
                 // otherwise save updated entry
             } else {
                 $this->cache->save($graphUri, $queryList);
             }
         }
     }
     // check for according triple pattern
     if (true === is_array($queryCacheContainer['triple_pattern'])) {
         foreach ($queryCacheContainer['triple_pattern'] as $patternKey) {
             $queryList = $this->cache->load($patternKey);
             unset($queryList[$query]);
             // if patternKey entry is empty after the operation, remove it from the cache
             if (0 == count($queryList)) {
                 $this->cache->remove($patternKey);
                 // otherwise save updated entry
             } else {
                 $this->cache->save($patternKey, $queryList);
             }
         }
     }
     /**
      * Remove query cache container
      */
     $this->cache->remove($query);
 }
开发者ID:guitarmarx,项目名称:Saft,代码行数:48,代码来源:QueryCache.php

示例9: saveLog

 /**
  * @param string $message
  * @param string $event
  * @param int|null $userID
  * @throws \Exception
  */
 public function saveLog($message, $event, $userID = null)
 {
     $eventLog = $this->getEventLog($event);
     if ($eventLog === null) {
         return;
         // todo monolog log
     }
     if (!$this->isEventLoggable($eventLog)) {
         return;
     }
     try {
         $user = null;
         if (isset($userID)) {
             $user = $this->em->getReference(User::class, $userID);
         }
         $newLog = new Log($message, $this->em->getReference(EventLog::class, $eventLog->getId()), $this->request->getRemoteAddress(), $user);
         $this->em->persist($newLog)->flush();
     } catch (ForeignKeyConstraintViolationException $e) {
         // todo if user doesn't exist
         $this->cache->remove(self::getEventLogCacheKey($event));
     }
 }
开发者ID:blitzik,项目名称:CMS,代码行数:28,代码来源:AppEventLogger.php

示例10: save

 /**
  * @param Role $role
  * @param array $permissionDefinitions
  * @throws DBALException
  * @throws \Exception
  */
 public function save(Role $role, array $permissionDefinitions)
 {
     $resources = $this->em->createQuery('SELECT r FROM ' . Resource::class . ' r INDEX BY r.id')->execute();
     $privileges = $this->em->createQuery('SELECT p FROM ' . Privilege::class . ' p INDEX BY p.id')->execute();
     try {
         $this->em->beginTransaction();
         $this->em->createQuery('DELETE ' . Permission::class . ' p
              WHERE p.role = :role')->execute(['role' => $role->getId()]);
         $parentRole = null;
         if ($role->hasParent()) {
             /** @var Role $parentRole */
             $parentRole = $this->em->find(Role::class, $role->getParentId());
         }
         foreach ($permissionDefinitions as $definition => $isAllowed) {
             $isAllowed = (bool) $isAllowed;
             $x = explode('-', $definition);
             // eg. 1-3
             /** @var \Users\Authorization\Resource $resource */
             $resource = $resources[$x[0]];
             /** @var Privilege $privilege */
             $privilege = $privileges[$x[1]];
             // check Users\Authorization\Authorizator ACL assembling
             // Role without parent
             // privilege: allowed -> must be in database
             // privilege: denied  -> does NOT have to be in database
             // Role with parent (all depths)
             /*
                               ------------------------------------------------------------
                                  parent    |    descendant    |    should be persisted?
                               ------------------------------------------------------------
                                  allowed         allowed                  NO
                                  allowed         denied                  YES
                                  denied          denied                  NO
                                  denied          allowed                 YES
                               ------------------------------------------------------------
                                 We save records where permission and denial differ
             */
             if ($parentRole !== null) {
                 // has parent
                 if ($this->authorizator->isAllowed($parentRole, $resource->getName(), $privilege->getName()) === $isAllowed) {
                     continue;
                 }
             } else {
                 // doesn't have parent
                 if ($isAllowed === false) {
                     continue;
                 }
             }
             $permission = new Permission($role, $resource, $privilege, $isAllowed);
             $this->em->persist($permission);
         }
         $this->em->flush();
         $this->em->commit();
         $this->cache->remove('acl');
         $this->onSuccessRolePermissionsEditing($role);
     } catch (\Exception $e) {
         $this->em->rollback();
         $this->em->close();
         // todo log error
         throw new $e();
     }
 }
开发者ID:blitzik,项目名称:CMS,代码行数:68,代码来源:RolePermissionsPersister.php

示例11: clearImageVersion

 /**
  * @param string $namespace
  * @param string $name
  */
 public function clearImageVersion($namespace, $name)
 {
     $this->cache->remove('version/' . $namespace . '/' . $name);
 }
开发者ID:josefzajac,项目名称:Nette-ImagesManager,代码行数:8,代码来源:CachedStorage.php

示例12: clearStringsCache

 /**
  * Clears strings cache
  * @return HQ\DbTranslator
  */
 public function clearStringsCache()
 {
     $cacheName = $this->getStringsCacheName();
     $this->cache->remove($cacheName);
     return $this;
 }
开发者ID:RiKap,项目名称:ErrorMonitoring,代码行数:10,代码来源:DbTranslator.php

示例13: deleteSection

 /**
  * @param int $section
  */
 public function deleteSection($section)
 {
     $this->cache->remove($section);
 }
开发者ID:CSHH,项目名称:website,代码行数:7,代码来源:MenuCache.php

示例14: cleanTargetCache

 private function cleanTargetCache(Brabijan\SeoComponents\Router\Target $target)
 {
     $this->cache->remove(serialize($target));
 }
开发者ID:brabijan,项目名称:nette-seo-components,代码行数:4,代码来源:Route.php

示例15: getValue

 /**
  * Vrátí nacachované hodnoty z controlleru.
  * @return mixed|NULL
  */
 public function getValue()
 {
     $files = $this->cache->load($this->getTokenizedCacheName($this->token));
     $this->cache->remove($this->getTokenizedCacheName($this->token));
     return $files;
 }
开发者ID:jzechy,项目名称:jquery-fileupload,代码行数:10,代码来源:FileUploadControl.php


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