ChainedFastBackendTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace Drupal\KernelTests\Core\Cache;
  3. use Drupal\Core\Cache\ChainedFastBackend;
  4. use Drupal\Core\Cache\DatabaseBackend;
  5. use Drupal\Core\Cache\PhpBackend;
  6. /**
  7. * Unit test of the fast chained backend using the generic cache unit test base.
  8. *
  9. * @group Cache
  10. */
  11. class ChainedFastBackendTest extends GenericCacheBackendUnitTestBase {
  12. /**
  13. * Creates a new instance of ChainedFastBackend.
  14. *
  15. * @return \Drupal\Core\Cache\ChainedFastBackend
  16. * A new ChainedFastBackend object.
  17. */
  18. protected function createCacheBackend($bin) {
  19. $consistent_backend = new DatabaseBackend(\Drupal::service('database'), \Drupal::service('cache_tags.invalidator.checksum'), $bin, 100);
  20. $fast_backend = new PhpBackend($bin, \Drupal::service('cache_tags.invalidator.checksum'));
  21. $backend = new ChainedFastBackend($consistent_backend, $fast_backend, $bin);
  22. // Explicitly register the cache bin as it can not work through the
  23. // cache bin list in the container.
  24. \Drupal::service('cache_tags.invalidator')->addInvalidator($backend);
  25. return $backend;
  26. }
  27. }