diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index db5c2f0..8630330 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -19,7 +19,7 @@ * * @ingroup cache */ -class DatabaseBackend implements CacheBackendInterface { +class DatabaseBackend implements CacheBackendInterface, ConfigurablePermanentTtlInterface { /** * @var string @@ -42,6 +42,11 @@ class DatabaseBackend implements CacheBackendInterface { protected $checksumProvider; /** + * The minimum permanent TTL. + */ + protected $minimumPermanentTtl = CacheBackendInterface::CACHE_PERMANENT; + + /** * Constructs a DatabaseBackend object. * * @param \Drupal\Core\Database\Connection $connection @@ -194,8 +199,10 @@ protected function doSetMultiple(array $items) { $values = array(); foreach ($items as $cid => $item) { + if (!isset($item['expire'] || $item['expire'] === CacheBackendInterface::CACHE_PERMANENT)) { + $item['expire'] = $this->maximumPermanentTtl; + } $item += array( - 'expire' => CacheBackendInterface::CACHE_PERMANENT, 'tags' => array(), ); @@ -356,6 +363,13 @@ public function removeBin() { } /** + * {@inheritdoc} + */ + function setMinimumPermamentTtl($ttl) { + $this->minimumPermanentTtl = $ttl; + } + + /** * Check if the cache bin exists and create it if not. */ protected function ensureBinExists() {