View source
<?php
namespace Drupal\supercache\Tests\Generic\Cache;
use Drupal\couchbasedrupal\CouchbaseManager;
use Drupal\couchbasedrupal\Cache\CouchbaseRawBackendFactory;
use Drupal\wincachedrupal\Cache\WincacheRawBackendFactory;
use Drupal\couchbasedrupal\Cache\CouchbaseBackendFactory;
use Drupal\wincachedrupal\Cache\WincacheBackendFactory;
use Drupal\supercache\Cache\ApcuRawBackendFactory;
use Drupal\supercache\Cache\DatabaseRawBackendFactory;
use Drupal\supercache\Cache\ChainedFastRawBackendFactory;
use Drupal\supercache\Cache\ChainedFastBackendFactory;
use Drupal\Core\Cache\ApcuBackendFactory;
use Drupal\Core\Cache\DatabaseBackendFactory;
use Drupal\Core\Site\Settings;
trait CacheServicesTrait {
protected function populateRawCacheServices() {
$logger = $this
->getMock(\Psr\Log\LoggerInterface::class);
$app_root = '/';
$site_path = 'mypath';
new Settings([
'chained_disable_shutdown' => TRUE,
]);
$settings = \Drupal\Core\Site\Settings::getInstance();
$manager = new CouchbaseManager($settings, $logger);
$connection = \Drupal\Core\Database\Database::getConnection();
$this->container
->set('rawbackend.wincache', new WincacheRawBackendFactory($app_root, $site_path));
$this->container
->set('rawbackend.couchbase', new CouchbaseRawBackendFactory($manager, $app_root, $site_path));
$this->container
->set('rawbackend.apcu', new ApcuRawBackendFactory($app_root, $site_path));
$this->container
->set('rawbackend.database', new DatabaseRawBackendFactory($connection));
$f = new ChainedFastRawBackendFactory($settings, 'rawbackend.couchbase', 'rawbackend.wincache');
$f
->setContainer($this->container);
$this->container
->set('rawbackend.chained.couchbase_wincache', $f);
$f = new ChainedFastRawBackendFactory($settings, 'rawbackend.database', 'rawbackend.wincache');
$f
->setContainer($this->container);
$this->container
->set('rawbackend.chained.database_wincache', $f);
$f = new ChainedFastRawBackendFactory($settings, 'rawbackend.couchbase', 'rawbackend.apcu');
$f
->setContainer($this->container);
$this->container
->set('rawbackend.chained.couchbase_apcu', $f);
$f = new ChainedFastRawBackendFactory($settings, 'rawbackend.database', 'rawbackend.apcu');
$f
->setContainer($this->container);
$this->container
->set('rawbackend.chained.database_apcu', $f);
$f = new ChainedFastRawBackendFactory($settings, 'rawbackend.database', 'rawbackend.couchbase');
$f
->setContainer($this->container);
$this->container
->set('rawbackend.chained.database_couchbase', $f);
return [
'rawbackend.wincache',
'rawbackend.couchbase',
'rawbackend.apcu',
'rawbackend.database',
'rawbackend.chained.couchbase_wincache',
'rawbackend.chained.database_wincache',
'rawbackend.chained.couchbase_apcu',
'rawbackend.chained.database_apcu',
'rawbackend.chained.database_couchbase',
];
}
protected function populateCacheServices() {
$logger = $this
->getMock(\Psr\Log\LoggerInterface::class);
$app_root = '/';
$site_path = 'mypath';
new Settings([
'chained_disable_shutdown' => TRUE,
]);
$settings = \Drupal\Core\Site\Settings::getInstance();
$manager = new CouchbaseManager($settings, $logger);
$connection = \Drupal\Core\Database\Database::getConnection();
$checksum = new \Drupal\supercache\Cache\DummyTagChecksum();
$this->container
->set('backend.wincache', new WincacheBackendFactory($app_root, $site_path, $checksum));
$this->container
->set('backend.couchbase', new CouchbaseBackendFactory($manager, $app_root, $site_path, $checksum, TRUE));
$this->container
->set('backend.apcu', new ApcuBackendFactory($app_root, $site_path, $checksum));
$this->container
->set('backend.database', new DatabaseBackendFactory($connection, $checksum));
$f = new ChainedFastBackendFactory($settings, 'backend.couchbase', 'backend.wincache');
$f
->setContainer($this->container);
$this->container
->set('backend.chained.couchbase_wincache', $f);
$f = new ChainedFastBackendFactory($settings, 'backend.database', 'backend.wincache');
$f
->setContainer($this->container);
$this->container
->set('backend.chained.database_wincache', $f);
$f = new ChainedFastBackendFactory($settings, 'backend.couchbase', 'backend.apcu');
$f
->setContainer($this->container);
$this->container
->set('backend.chained.couchbase_apcu', $f);
$f = new ChainedFastBackendFactory($settings, 'backend.database', 'backend.apcu');
$f
->setContainer($this->container);
$this->container
->set('backend.chained.database_apcu', $f);
$f = new ChainedFastBackendFactory($settings, 'backend.database', 'backend.couchbase');
$f
->setContainer($this->container);
$this->container
->set('backend.chained.database_couchbase', $f);
return [
'backend.wincache',
'backend.couchbase',
'backend.apcu',
'backend.database',
'backend.chained.couchbase_wincache',
'backend.chained.database_wincache',
'backend.chained.couchbase_apcu',
'backend.chained.database_apcu',
'backend.chained.database_couchbase',
];
}
}