You are here

protected function DrupalMemcacheFactory::initialize in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 modules/memcache/src/DrupalMemcacheFactory.php \Drupal\memcache\DrupalMemcacheFactory::initialize()

Initializes memcache settings.

1 call to DrupalMemcacheFactory::initialize()
DrupalMemcacheFactory::__construct in modules/memcache/src/DrupalMemcacheFactory.php

File

modules/memcache/src/DrupalMemcacheFactory.php, line 145
Contains \Drupal\memcache\DrupalMemcacheFactory.

Class

DrupalMemcacheFactory
Factory class for creation of Memcache objects.

Namespace

Drupal\memcache

Code

protected function initialize() {

  // If an extension is specified in settings.php, use that when available.
  $preferred = $this->settings
    ->get('memcache_extension', NULL);
  if (isset($preferred) && class_exists($preferred)) {
    $this->extension = $preferred;
  }
  elseif (class_exists('Memcache')) {
    $this->extension = 'Memcache';
  }
  elseif (class_exists('Memcached')) {
    $this->extension = 'Memcached';
  }

  // Values from settings.php
  $this->memcacheServers = $this->settings
    ->get('memcache_servers', array(
    '127.0.0.1:11211' => 'default',
  ));
  $this->memcacheBins = $this->settings
    ->get('memcache_bins', array(
    'default' => 'default',
  ));

  // Indicate whether to connect to memcache using a persistent connection.
  // Note: this only affects the Memcache PECL extension, and does not affect
  // the Memcached PECL extension.  For a detailed explanation see:
  // http://drupal.org/node/822316#comment-4427676
  $this->memcachePersistent = $this->settings
    ->get('memcache_persistent', FALSE);
}