diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php index 7f04f0e900b330477f8cc1a067166fbb4f885413..b64fd7177bd6c410ebdc0e3eda882a229f02e90b 100644 --- a/core/lib/Drupal/Core/Cache/ApcuBackend.php +++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php @@ -68,7 +68,7 @@ public function __construct($bin, $site_prefix, CacheTagsChecksumInterface $chec * @return string * The APCu key for the cache item ID. */ - protected function getApcuKey($cid) { + public function getApcuKey($cid) { return $this->binPrefix . $cid; } @@ -178,14 +178,8 @@ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANEN $cache->serialized = 0; $cache->data = $data; - // apc_store()'s $ttl argument can be omitted but also set to 0 (zero), - // in which case the value will persist until it's removed from the cache or - // until the next cache clear, restart, etc. This is what we want to do - // when $expire equals CacheBackendInterface::CACHE_PERMANENT. - if ($expire === CacheBackendInterface::CACHE_PERMANENT) { - $expire = 0; - } - apc_store($this->getApcuKey($cid), $cache, $expire); + // Expiration is handled by our own prepareItem(), not APCu. + apc_store($this->getApcuKey($cid), $cache); } /** diff --git a/core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php b/core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php index fcb55779c806c7b02563ef270a67816f97254e83..fafac7ed4ce0c877cc14d102e8ae2f8c43ca553b 100644 --- a/core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php +++ b/core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php @@ -87,6 +87,15 @@ public function testSetGet() { return; } parent::testSetGet(); + + // Make sure entries are permanent (i.e. no TTL). + $backend = $this->getCacheBackend($this->getTestBin()); + $key = $backend->getApcuKey('TEST8'); + foreach (new \APCIterator('user', '/^' . $key . '/') as $item) { + $this->assertEqual(0, $item['ttl']); + $found = TRUE; + } + $this->assertTrue($found); } /**