本文整理汇总了PHP中Drupal\Core\Cache\CacheBackendInterface::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheBackendInterface::delete方法的具体用法?PHP CacheBackendInterface::delete怎么用?PHP CacheBackendInterface::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Cache\CacheBackendInterface
的用法示例。
在下文中一共展示了CacheBackendInterface::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onFieldDefinitionDelete
/**
* {@inheritdoc}
*/
public function onFieldDefinitionDelete(FieldDefinitionInterface $field_definition)
{
$entity_type_id = $field_definition->getTargetEntityTypeId();
$bundle = $field_definition->getTargetBundle();
$field_name = $field_definition->getName();
// Notify the storage about the field deletion.
$this->entityTypeManager->getStorage($entity_type_id)->onFieldDefinitionDelete($field_definition);
// Unset the bundle from the bundle field map key value collection.
$bundle_field_map = $this->keyValueFactory->get('entity.definitions.bundle_field_map')->get($entity_type_id);
unset($bundle_field_map[$field_name]['bundles'][$bundle]);
if (empty($bundle_field_map[$field_name]['bundles'])) {
// If there are no bundles left, remove the field from the map.
unset($bundle_field_map[$field_name]);
}
$this->keyValueFactory->get('entity.definitions.bundle_field_map')->set($entity_type_id, $bundle_field_map);
// Delete the cache entry.
$this->cacheBackend->delete('entity_field_map');
// If the field map is initialized, update it as well, so that calls to it
// do not have to rebuild it again.
if ($field_map = $this->entityFieldManager->getFieldMap()) {
unset($field_map[$entity_type_id][$field_name]['bundles'][$bundle]);
if (empty($field_map[$entity_type_id][$field_name]['bundles'])) {
unset($field_map[$entity_type_id][$field_name]);
}
$this->entityFieldManager->setFieldMap($field_map);
}
}
示例2: onRequestSent
/**
* Responds after a request has finished, but before it is sent to the client.
*
* @param \Guzzle\Common\Event $event
* The Guzzle event object.
*/
public function onRequestSent(Event $event)
{
$request = $event['request'];
$response = $event['response'];
// Handle permanent redirects by setting the redirected URL so that the
// client can grab it quickly.
$redirect = FALSE;
$url = $old_url = $request->getUrl();
if ($previous_response = $response->getPreviousResponse()) {
if ($previous_response->getStatusCode() == 301 && ($location = $previous_response->getLocation())) {
$response->getParams()->set('feeds.redirect', $location);
$redirect = TRUE;
$url = $request->getUrl();
}
}
$cache_hit = $response->getStatusCode() == 304;
if ($redirect) {
// Delete the old cache entry.
$this->cacheBackend->delete($this->getCacheKey($old_url));
// Not sure if the repeated requests are smart enough to find the
// redirect, so cache the old URL with the new response.
static::$downloadCache[$old_url] = $response;
}
if ($redirect || !$cache_hit) {
$cache = new \stdClass();
$cache->headers = array_change_key_case($response->getHeaders()->toArray());
// @todo We should only cache for certain status codes.
$cache->code = $response->getStatusCode();
$this->cacheBackend->set($this->getCacheKey($url), $cache);
}
// Set in-page download cache.
static::$downloadCache[$url] = $response;
}
示例3: clear
/**
* {@inheritdoc}
*/
public function clear()
{
$this->reset();
if ($this->tags) {
Cache::invalidateTags($this->tags);
} else {
$this->cache->delete($this->getCid());
}
}
示例4: clear
/**
* {@inheritdoc}
*/
public function clear()
{
$this->reset();
if ($this->tags) {
Cache::deleteTags($this->tags);
} else {
$this->cache->delete($this->cid);
}
}
示例5: clearCachedDefinitions
/**
* {@inheritdoc}
*/
public function clearCachedDefinitions()
{
if ($this->cacheBackend) {
if ($this->cacheTags) {
// Use the cache tags to clear the cache.
Cache::invalidateTags($this->cacheTags);
} else {
$this->cacheBackend->delete($this->cacheKey);
}
}
$this->definitions = NULL;
}
示例6: rename
/**
* {@inheritdoc}
*/
public function rename($name, $new_name)
{
// If the cache was the first to be deleted, another process might start
// rebuilding the cache before the storage is renamed.
if ($this->storage->rename($name, $new_name)) {
$this->cache->delete($this->getCacheKey($name));
$this->cache->delete($this->getCacheKey($new_name));
$this->findByPrefixCache = array();
return TRUE;
}
return FALSE;
}
示例7: rename
/**
* Implements Drupal\Core\Config\StorageInterface::rename().
*/
public function rename($name, $new_name)
{
// If the cache was the first to be deleted, another process might start
// rebuilding the cache before the storage is renamed.
if ($this->storage->rename($name, $new_name)) {
$this->cache->delete($name);
$this->cache->delete($new_name);
Cache::deleteTags(array($this::FIND_BY_PREFIX_CACHE_TAG => TRUE));
$this->findByPrefixCache = array();
return TRUE;
}
return FALSE;
}
示例8: expireFiles
/**
* Submit handler that explicitly clears cache_example_files_count from cache.
*/
public function expireFiles($form, &$form_state)
{
// Clear cached data. This function will delete cached object from cache
// bin.
//
// The first argument is cache id to be deleted. Since we've provided it
// explicitly, it will be removed whether or not it has an associated
// expiration time. The second argument (required here) is the cache bin.
// Using cache_clear_all() explicitly in this way
// forces removal of the cached item.
$this->cacheBackend->delete('cache_example_files_count');
// Display message to the user.
drupal_set_message($this->t('Cached data key "cache_example_files_count" was cleared.'), 'status');
}
示例9: resetImplementations
/**
* {@inheritdoc}
*/
public function resetImplementations()
{
$this->implementations = NULL;
$this->hookInfo = NULL;
$this->alterFunctions = NULL;
// We maintain a persistent cache of hook implementations in addition to the
// static cache to avoid looping through every module and every hook on each
// request. Benchmarks show that the benefit of this caching outweighs the
// additional database hit even when using the default database caching
// backend and only a small number of modules are enabled. The cost of the
// $this->cacheBackend->get() is more or less constant and reduced further
// when non-database caching backends are used, so there will be more
// significant gains when a large number of modules are installed or hooks
// invoked, since this can quickly lead to
// \Drupal::moduleHandler()->implementsHook() being called several thousand
// times per request.
$this->cacheBackend->set('module_implements', array());
$this->cacheBackend->delete('hook_info');
}
示例10: onFeedDeleteMultiple
/**
* {@inheritdoc}
*/
public function onFeedDeleteMultiple(array $feeds)
{
foreach ($feeds as $feed) {
$this->cache->delete($this->getCacheKey($feed));
}
}
示例11: delete
/**
* {@inheritdoc}
*/
protected function delete($name)
{
$this->cache->delete($name);
unlink($this->fileStorage->getFilePath($name));
}
示例12: clearCaptchaPlacementCacheSubmit
/**
* Submit callback; clear CAPTCHA placement cache.
*
* @param array $form
* Form structured array.
* @param FormStateInterface $form_state
* Form state structured array.
*/
public function clearCaptchaPlacementCacheSubmit(array $form, FormStateInterface $form_state)
{
$this->cacheBackend->delete('captcha_placement_map_cache');
drupal_set_message($this->t('Cleared the CAPTCHA placement cache.'));
}
示例13: clearCache
/**
* {@inheritdoc}
*/
public function clearCache()
{
$this->map = NULL;
$this->cache->delete('commerce_product.line_item_type_map');
}
示例14: delete
/**
* {@inheritdoc}
*/
public function delete($cid)
{
return $this->cacheBackend->delete($cid);
}
示例15: clearCachedDefinitions
/**
* {@inheritdoc}
*/
public function clearCachedDefinitions()
{
$this->definitions = NULL;
$this->schemaStorage->reset();
$this->cache->delete($this::CACHE_ID);
}