public function BackendExpireTests::testExpirations in Supercache 8
Same name and namespace in other branches
- 2.0.x src/Tests/Generic/Cache/BackendExpireTests.php \Drupal\supercache\Tests\Generic\Cache\BackendExpireTests::testExpirations()
Test the saving and restoring of a string.
1 method overrides BackendExpireTests::testExpirations()
- ApcuRawBackendExpireTests::testExpirations in src/
Tests/ Cache/ ApcuRawBackendExpireTests.php - Test the saving and restoring of a string.
File
- src/
Tests/ Generic/ Cache/ BackendExpireTests.php, line 32
Class
- BackendExpireTests
- Test saving functions.
Namespace
Drupal\supercache\Tests\Generic\CacheCode
public function testExpirations() {
$name = 'test-data';
$value = 'this is the data';
// Cascade expiration in different binaries.
$this->backend
->set($name, $value, time() + 3);
$this
->assertExists('Item exists', $value, $name, $this->backend);
$this->backend2
->set($name, $value, time() + 7);
$this
->assertExists('Item exists', $value, $name, $this->backend2);
sleep(5);
$this
->refreshRequestTime($this->backend);
$this
->assertRemoved('Item expired', $name, $this->backend);
$this
->assertExists('Item exists', $value, $name, $this->backend2);
sleep(5);
$this
->refreshRequestTime($this->backend2);
$this
->assertRemoved('Item expired', $name, $this->backend2);
// Test that permanent items do not expire... at some point
// one of the backends was passing through the -1 to the storage
// backend or even calculating negative expirations...
$this->backend
->set($name, $value, \Drupal\Core\Cache\Cache::PERMANENT);
sleep(5);
$this
->assertExists('Item exists', $value, $name, $this->backend);
}