diff --git a/core/core.services.yml b/core/core.services.yml index 32b0bd5..3208606 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -207,31 +207,31 @@ services: tags: - { name: cache.bin } factory: cache_factory:get - arguments: [default, ['minimum_permanent_ttl', 86400]] + arguments: [default, ['override_permanent_ttl', 86400]] cache.entity: class: Drupal\Core\Cache\CacheBackendInterface tags: - { name: cache.bin } factory: cache_factory:get - arguments: [entity, ['minimum_permanent_ttl', 86400]] + arguments: [entity, ['override_permanent_ttl', 86400]] cache.menu: class: Drupal\Core\Cache\CacheBackendInterface tags: - { name: cache.bin } factory: cache_factory:get - arguments: [menu, ['minimum_permanent_ttl', 86400]] + arguments: [menu, ['override_permanent_ttl', 86400]] cache.render: class: Drupal\Core\Cache\CacheBackendInterface tags: - { name: cache.bin } factory: cache_factory:get - arguments: [render, ['minimum_permanent_ttl', 86400]] + arguments: [render, ['override_permanent_ttl', 86400]] cache.data: class: Drupal\Core\Cache\CacheBackendInterface tags: - { name: cache.bin } factory: cache_factory:get - arguments: [data, ['minimum_permanent_ttl', 86400]] + arguments: [data, ['override_permanent_ttl', 86400]] cache.discovery: class: Drupal\Core\Cache\CacheBackendInterface tags: diff --git a/core/lib/Drupal/Core/Cache/ConfigurablePermanentTtlInterface.php b/core/lib/Drupal/Core/Cache/ConfigurablePermanentTtlInterface.php index 4dbc8a4..ed33603 100644 --- a/core/lib/Drupal/Core/Cache/ConfigurablePermanentTtlInterface.php +++ b/core/lib/Drupal/Core/Cache/ConfigurablePermanentTtlInterface.php @@ -2,7 +2,7 @@ namespace Drupal\Core\Cache; /** - * Defines an interface for setting a configurable minimum permanent TTL. + * Defines an interface for setting a configurable permanent TTL. * * This allows cache backends with restrictions on storage space to set a * shorter TTL for 'permanent' cache items, so that they get expired by garbage @@ -10,7 +10,7 @@ * to allow 'jitter' to be applied so that items set immediately after a cache * clear do not all expire at the same time. Cache backends should assign jitter * higher rather than lower to avoid the risk of cache stampedes, since the - * minimum ttl could potentially be set very low for some use cases. + * configured ttl could potentially be set very low for some use cases. * * @ingroup cache */ @@ -21,6 +21,6 @@ * * @param int $ttl */ - function setMinimumPermanentTtl($ttl); + function setOverridePermanentTtl($ttl); } diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index 7582869..9b50cc5 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -22,7 +22,7 @@ class DatabaseBackend implements CacheBackendInterface, ConfigurablePermanentTtlInterface { /** - * The 'jitter' multiplier, applied to the minimum TTL to avoid stampedes. + * The 'jitter' multiplier, applied to the permanent TTL to avoid stampedes. * * @var float */ @@ -49,9 +49,9 @@ class DatabaseBackend implements CacheBackendInterface, ConfigurablePermanentTtl protected $checksumProvider; /** - * The minimum permanent TTL. + * The overridden permanent TTL. */ - protected $minimumPermanentTtl = CacheBackendInterface::CACHE_PERMANENT; + protected $overridePermanentTtl = CacheBackendInterface::CACHE_PERMANENT; /** * Constructs a DatabaseBackend object. @@ -207,7 +207,7 @@ protected function doSetMultiple(array $items) { foreach ($items as $cid => $item) { if (!isset($item['expire']) || $item['expire'] === CacheBackendInterface::CACHE_PERMANENT) { - if ($this->minimumPermanentTtl === CacheBackendInterface::CACHE_PERMANENT) { + if ($this->overridePermanentTtl === CacheBackendInterface::CACHE_PERMANENT) { $item['expire'] = CacheBackendInterface::CACHE_PERMANENT; } else { @@ -261,10 +261,10 @@ protected function doSetMultiple(array $items) { /** * Calculate permanent expiry. * - * @return an expires timestamp based on the minimum TTL with added 'jitter'. + * @return an expires timestamp based on the override TTL with added 'jitter'. */ protected function calculatePermanentExpire() { - $minimum = $this->minimumPermanentTtl; + $minimum = $this->overridePermanentTtl; return rand($minimum, $minimum * self::JITTER_MULTIPLIER) + REQUEST_TIME; } @@ -387,8 +387,8 @@ public function removeBin() { /** * {@inheritdoc} */ - public function setMinimumPermanentTtl($ttl) { - $this->minimumPermanentTtl = $ttl; + public function setOverridePermanentTtl($ttl) { + $this->overridePermanentTtl = $ttl; } /** diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackendFactory.php b/core/lib/Drupal/Core/Cache/DatabaseBackendFactory.php index 325bd49..05459b2 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackendFactory.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackendFactory.php @@ -43,8 +43,8 @@ function __construct(Connection $connection, CacheTagsChecksumInterface $checksu */ function get($bin, array $options = []) { $class = new DatabaseBackend($this->connection, $this->checksumProvider, $bin); - if (isset($options['minimum_permanent_ttl'])) { - $class->setMinimumPermanentTtl($options['minimum_permanent_ttl']); + if (isset($options['override_permanent_ttl'])) { + $class->setOverridePermanentTtl($options['override_permanent_ttl']); } return $class; } diff --git a/core/modules/system/src/Tests/Cache/DatabaseBackendUnitTest.php b/core/modules/system/src/Tests/Cache/DatabaseBackendUnitTest.php index e3aff07..63a6f8f 100644 --- a/core/modules/system/src/Tests/Cache/DatabaseBackendUnitTest.php +++ b/core/modules/system/src/Tests/Cache/DatabaseBackendUnitTest.php @@ -55,11 +55,11 @@ public function testSetGet() { } /** - * Test minimumPermanentTtl. + * Test overridePermanentTtl. */ - function testMinimumPermanentTtl() { + function testOverridePermanentTtl() { $backend = $this->getCacheBackend(); - $backend->setMinimumPermanentTtl(2); + $backend->setOverridePermanentTtl(2); $cid = 'test'; $value = 'test'; $backend->set($cid, $value);