diff --git a/core/lib/Drupal/Core/Cache/BackendChain.php b/core/lib/Drupal/Core/Cache/BackendChain.php index 548d62df029..d3fac6e111d 100644 --- a/core/lib/Drupal/Core/Cache/BackendChain.php +++ b/core/lib/Drupal/Core/Cache/BackendChain.php @@ -165,15 +165,6 @@ class BackendChain implements CacheBackendInterface { } } - /** - * Implements Drupal\Core\Cache\CacheBackendInterface::expire(). - */ - public function deleteExpired() { - foreach ($this->backends as $backend) { - $backend->deleteExpired(); - } - } - /** * Implements Drupal\Core\Cache\CacheBackendInterface::invalidate(). */ diff --git a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php index b29ef9b3c30..d38a0946cef 100644 --- a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php +++ b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php @@ -43,8 +43,8 @@ namespace Drupal\Core\Cache; * @endcode * * There are two ways to "remove" a cache item: - * - Deletion (using delete(), deleteMultiple(), deleteTags(), deleteAll() or - * deleteExpired()): Permanently removes the item from the cache. + * - Deletion (using delete(), deleteMultiple(), deleteTags() or deleteAll()): + * Permanently removes the item from the cache. * - Invalidation (using invalidate(), invalidateMultiple(), invalidateTags() * or invalidateAll()): a "soft" delete that only marks the items as * "invalid", meaning "not fresh" or "not fresh enough". Invalid items are @@ -163,7 +163,6 @@ interface CacheBackendInterface { * @see Drupal\Core\Cache\CacheBackendInterface::deleteMultiple() * @see Drupal\Core\Cache\CacheBackendInterface::deleteTags() * @see Drupal\Core\Cache\CacheBackendInterface::deleteAll() - * @see Drupal\Core\Cache\CacheBackendInterface::deleteExpired() */ public function delete($cid); @@ -183,7 +182,6 @@ interface CacheBackendInterface { * @see Drupal\Core\Cache\CacheBackendInterface::delete() * @see Drupal\Core\Cache\CacheBackendInterface::deleteTags() * @see Drupal\Core\Cache\CacheBackendInterface::deleteAll() - * @see Drupal\Core\Cache\CacheBackendInterface::deleteExpired() */ public function deleteMultiple(array $cids); @@ -205,7 +203,6 @@ interface CacheBackendInterface { * @see Drupal\Core\Cache\CacheBackendInterface::delete() * @see Drupal\Core\Cache\CacheBackendInterface::deleteMultiple() * @see Drupal\Core\Cache\CacheBackendInterface::deleteAll() - * @see Drupal\Core\Cache\CacheBackendInterface::deleteExpired() */ public function deleteTags(array $tags); @@ -216,21 +213,9 @@ interface CacheBackendInterface { * @see Drupal\Core\Cache\CacheBackendInterface::delete() * @see Drupal\Core\Cache\CacheBackendInterface::deleteMultiple() * @see Drupal\Core\Cache\CacheBackendInterface::deleteTags() - * @see Drupal\Core\Cache\CacheBackendInterface::deleteExpired() */ public function deleteAll(); - /** - * Deletes expired items from the cache. - * - * @see Drupal\Core\Cache\CacheBackendInterface::delete() - * @see Drupal\Core\Cache\CacheBackendInterface::deleteMultiple() - * @see Drupal\Core\Cache\CacheBackendInterface::deleteTags() - * @see Drupal\Core\Cache\CacheBackendInterface::deleteAll() - * @see Drupal\Core\Cache\CacheBackendInterface::deleteExpired() - */ - public function deleteExpired(); - /** * Marks a cache item as invalid. * diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index e4d86c6b5ad..1c3f2a0bca5 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -192,16 +192,6 @@ class DatabaseBackend implements CacheBackendInterface { Database::getConnection()->truncate($this->bin)->execute(); } - /** - * Implements Drupal\Core\Cache\CacheBackendInterface::deleteExpired(). - */ - public function deleteExpired() { - Database::getConnection()->delete($this->bin) - ->condition('expire', CacheBackendInterface::CACHE_PERMANENT, '<>') - ->condition('expire', REQUEST_TIME, '<') - ->execute(); - } - /** * Implements Drupal\Core\Cache\CacheBackendInterface::invalidate(). */ @@ -251,7 +241,10 @@ class DatabaseBackend implements CacheBackendInterface { * Implements Drupal\Core\Cache\CacheBackendInterface::garbageCollection(). */ public function garbageCollection() { - $this->deleteExpired(); + Database::getConnection()->delete($this->bin) + ->condition('expire', CacheBackendInterface::CACHE_PERMANENT, '<>') + ->condition('expire', REQUEST_TIME, '<') + ->execute(); } /** diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php index 5cd895ff6ee..ac83a06ff35 100644 --- a/core/lib/Drupal/Core/Cache/MemoryBackend.php +++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php @@ -138,16 +138,6 @@ class MemoryBackend implements CacheBackendInterface { $this->cache = array(); } - /** - * Implements Drupal\Core\Cache\CacheBackendInterface::deleteExpired(). - * - * Cache expiration is not implemented for MemoryBackend as this backend only - * persists during a single request and expiration are done using - * REQUEST_TIME. - */ - public function deleteExpired() { - } - /** * Implements Drupal\Core\Cache\CacheBackendInterface::invalidate(). */ diff --git a/core/lib/Drupal/Core/Cache/NullBackend.php b/core/lib/Drupal/Core/Cache/NullBackend.php index 8b3565d6175..16c03312f09 100644 --- a/core/lib/Drupal/Core/Cache/NullBackend.php +++ b/core/lib/Drupal/Core/Cache/NullBackend.php @@ -62,11 +62,6 @@ class NullBackend implements CacheBackendInterface { */ public function deleteAll() {} - /** - * Implements Drupal\Core\Cache\CacheBackendInterface::deleteExpired(). - */ - public function deleteExpired() {} - /** * Implements Drupal\Core\Cache\CacheBackendInterface::deleteTags(). */ diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/CacheTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Cache/CacheTestBase.php index dd1dea990ed..e2c552b2d98 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Cache/CacheTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Cache/CacheTestBase.php @@ -87,18 +87,4 @@ abstract class CacheTestBase extends WebTestBase { $cached = cache($bin)->get($cid); $this->assertFalse($cached, $message); } - - /** - * Performs a general wipe of the bin. - * - * @param $bin - * The bin to perform the wipe on. - */ - protected function generalWipe($bin = NULL) { - if ($bin == NULL) { - $bin = $this->default_bin; - } - - cache($bin)->deleteExpired(); - } } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 315add70f22..cd016f4370f 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -3550,7 +3550,7 @@ function system_cron() { $cache_bins = array_merge(module_invoke_all('cache_flush'), array('form', 'menu')); foreach ($cache_bins as $bin) { - cache($bin)->deleteExpired(); + cache($bin)->garbageCollection(); } // Cleanup the batch table and the queue for failed batches.