本文整理汇总了PHP中Doctrine\Common\Cache\Cache::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::delete方法的具体用法?PHP Cache::delete怎么用?PHP Cache::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Cache\Cache
的用法示例。
在下文中一共展示了Cache::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
/**
* @Route("/entry-point/{mac}", defaults={"mac" = null})
* @Method({"GET", "POST"})
* @Template()
*/
public function indexAction(Request $request, $mac)
{
// Attempting to do anything here as a logged in user will fail. Set the current user token to null to log user out.
$this->get('security.token_storage')->setToken(null);
if (!$mac) {
if (!$request->getSession()->get('auth-data')) {
// No MAC code, nothing in the session, so we can't help - return to front page.
return $this->redirectToRoute('barbon_hostedapi_app_index_index');
}
} else {
$cacheKey = sprintf('mac-%s', $mac);
// If MAC isn't found in the cache, it's already been processed - redirect back to this route without the MAC, and try again.
if (!$this->cache->contains($cacheKey)) {
return $this->redirectToRoute('barbon_hostedapi_landlord_authentication_entrypoint_index');
}
// store data to session and empty the cache
$authData = unserialize($this->cache->fetch($cacheKey));
$request->getSession()->set('auth-data', $authData);
$this->cache->delete($cacheKey);
}
// Decide which tab should start as visible, so that is a registration attempt is in progress it re-shows that tab.
$selectedTab = $request->query->get('action') ?: 'register';
if ($request->isMethod(Request::METHOD_POST)) {
if ($request->request->has('direct_landlord')) {
$selectedTab = 'register';
}
}
return array('selectedTab' => $selectedTab);
}
示例2: removeTags
/**
* {@inheritdoc}
*/
public function removeTags(array $tags)
{
foreach ($tags as $tag) {
// doctrine does not care if the key does not exist.
$this->cache->delete($tag);
}
}
示例3: getMetadataForClass
/**
* Get metadata for a certain class - loads once and caches
* @param string $className
* @throws \Drest\DrestException
* @return ClassMetaData $metaData
*/
public function getMetadataForClass($className)
{
if (isset($this->loadedMetadata[$className])) {
return $this->loadedMetadata[$className];
}
// check the cache
if ($this->cache !== null) {
$classMetadata = $this->cache->fetch($this->cache_prefix . $className);
if ($classMetadata instanceof ClassMetaData) {
if ($classMetadata->expired()) {
$this->cache->delete($this->cache_prefix . $className);
} else {
$this->loadedMetadata[$className] = $classMetadata;
return $classMetadata;
}
}
}
$classMetadata = $this->driver->loadMetadataForClass($className);
if ($classMetadata !== null) {
$this->loadedMetadata[$className] = $classMetadata;
if ($this->cache !== null) {
$this->cache->save($this->cache_prefix . $className, $classMetadata);
}
return $classMetadata;
}
if (is_null($this->loadedMetadata[$className])) {
throw DrestException::unableToLoadMetaDataFromDriver();
}
return $this->loadedMetadata[$className];
}
示例4: removeObject
public function removeObject($object)
{
$class = $this->getClassMetadata();
$identifier = $this->getObjectIdentifier($object);
$identifier = $identifier[$class->identifier[0]];
$this->cache->delete($identifier);
}
示例5: deleteItem
/**
* {@inheritdoc}
*/
public function deleteItem($key)
{
if (!is_string($key)) {
throw new InvalidArgumentException('Passed key is invalid');
}
return $this->cache->delete($key);
}
示例6: stop
/**
* {@inheritdoc}
*/
public function stop($token)
{
if (!$this->exists($token)) {
return;
}
$this->dataCache->delete($token);
}
示例7: internalRemoveItem
/**
* {@inheritDoc}
*/
protected function internalRemoveItem(&$normalizedKey)
{
$key = $this->getOptions()->getNamespace() . $normalizedKey;
if (!$this->cache->contains($key)) {
return false;
}
return $this->cache->delete($key);
}
示例8: persistConfig
/**
* @param PersistConfigEvent $event
*/
public function persistConfig(PersistConfigEvent $event)
{
$event->getConfigManager()->calculateConfigChangeSet($event->getConfig());
$change = $event->getConfigManager()->getConfigChangeSet($event->getConfig());
if ($event->getConfig()->getId()->getScope() == 'email' && isset($change['available_in_template'])) {
$this->cache->delete($this->cacheKey);
}
}
示例9: ok
/**
* Set the state.
*
* @param bool $ok
* @param string|null $name
*/
public function ok($ok, $name = null)
{
$ok = (bool) $ok;
$key = $this->getCacheKey($name);
if ($ok === true) {
$this->cache->delete($key);
} else {
$this->cache->save($key, 1, $this->ttl);
}
}
示例10: persistConfig
/**
* @param PersistConfigEvent $event
*/
public function persistConfig(PersistConfigEvent $event)
{
$config = $event->getConfig();
if ($config->getId()->getScope() !== 'email') {
return;
}
$change = $event->getConfigManager()->getConfigChangeSet($config);
if (isset($change['available_in_template'])) {
$this->cache->delete($this->cacheKey);
}
}
示例11: preFlush
/**
* @param PreFlushConfigEvent $event
*/
public function preFlush(PreFlushConfigEvent $event)
{
$config = $event->getConfig('email');
if (null === $config || $event->isEntityConfig()) {
return;
}
$changeSet = $event->getConfigManager()->getConfigChangeSet($config);
if (isset($changeSet['available_in_template'])) {
$this->cache->delete($this->cacheKey);
}
}
示例12: reset
public function reset($class = null)
{
if ($class === null) {
if ($this->cacheProvider instanceof \Doctrine\Common\Cache\FlushableCache) {
$this->cacheProvider->flushAll();
}
return parent::reset($class);
}
$id = $class . '#info';
$this->cacheProvider->delete($id);
return parent::reset($class);
}
示例13: invalidate
/** @inheritdoc */
public function invalidate($restaurantId)
{
if ($this->cache->contains($restaurantId)) {
$cached = $this->cache->fetch($restaurantId)['cached']->getTimestamp();
$now = (new \DateTime())->getTimestamp();
if ($now - $cached < 60) {
throw new EnhanceYourCalmException();
}
$this->cache->delete($restaurantId);
return true;
}
return false;
}
示例14: removePathAndFilter
protected function removePathAndFilter($path, $filter)
{
$indexKey = $this->generateIndexKey($this->generateCacheKey($path, $filter));
if (!$this->cache->contains($indexKey)) {
return;
}
$index = $this->cache->fetch($indexKey);
if (null === $path) {
foreach ($index as $eachCacheKey) {
$this->cache->delete($eachCacheKey);
}
$index = array();
} else {
$cacheKey = $this->generateCacheKey($path, $filter);
if (false !== ($indexIndex = array_search($cacheKey, $index))) {
unset($index[$indexIndex]);
$this->cache->delete($cacheKey);
}
}
if (empty($index)) {
$this->cache->delete($indexKey);
} else {
$this->cache->save($indexKey, $index);
}
}
示例15: removeRolePermission
/**
* {@inheritdoc}
*/
public function removeRolePermission(Role $role, Permission $permission)
{
$this->driver->removeRolePermission($role, $permission);
// Invalidate cache
$cacheId = sprintf('roles/%s', $role->getRoleName());
$this->cache->delete($cacheId);
}