Drupal 8 Wincache Integration

Drupal 8 Wincache Integration

Piece of Cake

Wether you are enjoying the incredible Azure ecosystem, need to deploy on Windows due to business requirements or you have any other reason to deploy on Windows, the basic tool to run Drupal 8 on Windows with reasonable performance - the WIncache module - is already available.

Wincache Drupal

Wincache integration with Drupal is now more important than ever because several core components rely on in-memory caching to work, and will automatically use the APCu/APC extension:

  • The class loader cache (\Symfony\Component\ClassLoader\WincacheClassLoader)
  • The file cache (\Drupal\Component\FileCache\FileCache)
  • The chained fast backend (\Drupal\Core\Cache\ChainedFastBackend)

Thanks to the flexibility of Drupal 8, setting up Wincache is much easier than before. 

You can enable the basic Wincache integration with 3 easy steps:

1. Enable the module, it will automatically modify the service container to use Wincache as the fastBackend in the ChainedFastBackend.

2. Replace the default file cache, in settings.php:

// Need to register the namespace....
if (class_exists(\Composer\Autoload\ClassLoader::class)) {
  $loader = new \Composer\Autoload\ClassLoader();
  $loader->addPsr4('Drupal\\wincachedrupal\\', 'modules/wincachedrupal/src');

$settings['file_cache']['default'] = [
    'class' => '\Drupal\Component\FileCache\FileCache',
    'cache_backend_class' => \Drupal\wincachedrupal\Cache\WincacheFileCacheBackend::class,
    'cache_backend_configuration' => [],

3. Tell Drupal to use the Wincache class loader, in settings.php:

if ($settings['hash_salt']) {
  $prefix = 'drupal.' . hash('sha256', 'drupal.' . $settings['hash_salt']);
  $loader = new \Symfony\Component\ClassLoader\WincacheClassLoader($prefix, $class_loader);
  $loader ->register();
  $class_loader = $loader ;

This basic setup will get you up and running at the same speed as a Drupal 8 installation with APCu enabled.

The Wincache module also includes experimental implementations of the lock backend, key value storage - with database persistent backing - and others.

If you are using Drupal 7 the Wincache module includes a backported implementation of the ChainedFastBackend that will make your application much more fast on cold starts while leveraging the Wincache user cache storage.

Try this blazing fast setup (only suitable for small sites) on Drupal 7:

$conf['cache_backends'][] = 'sites/all/modules/contrib/wincachedrupal/drupal_win_cache.inc';
$conf['cache_backends'][] = 'sites/all/modules/contrib/wincachedrupal/ChainedFastBackend.inc';

$conf['fastBackend'] = 'DrupalWinCache';
$conf['consistentBackend'] = 'DrupalDatabaseCache';

$conf['cache_default_class'] = 'ChainedFastBackend';



Error on page /admin/reports/status
PHP Fatal error: Class name must be a valid object or a string in C:\WEB\drupal8\core\lib\Drupal\Core\Entity\Annotation\EntityType.php on line 63
After wincache.ocenabled=1 in php.ini

Add new comment

By: root Thursday, November 19, 2015 - 12:57