You are here

class MemcacheSettings in Memcache API and Integration 8.2

Class for holding Memcache related config.

Hierarchy

Expanded class hierarchy of MemcacheSettings

4 files declare their use of MemcacheSettings
DriverBase.php in src/Driver/DriverBase.php
MemcachedConnection.php in src/Connection/MemcachedConnection.php
MemcacheDriverFactory.php in src/Driver/MemcacheDriverFactory.php
MemcacheSettingsTest.php in tests/src/Unit/MemcacheSettingsTest.php
1 string reference to 'MemcacheSettings'
memcache.services.yml in ./memcache.services.yml
memcache.services.yml
1 service uses MemcacheSettings
memcache.settings in ./memcache.services.yml
Drupal\memcache\MemcacheSettings

File

src/MemcacheSettings.php, line 10

Namespace

Drupal\memcache
View source
class MemcacheSettings {

  /**
   * Array with the settings.
   *
   * @var array
   */
  protected $settings = [];

  /**
   * Constructor.
   *
   * @param \Drupal\Core\Site\Settings $settings
   *   The site settings instance.
   */
  public function __construct(Settings $settings) {
    $this->settings = $settings
      ->get('memcache', []);
  }

  /**
   * Returns a memcache setting.
   *
   * Settings can be set in settings.php in the $settings['memcache'] array and
   * requested by this function. Settings should be used over configuration for
   * read-only, possibly low bootstrap configuration that is environment
   * specific.
   *
   * @param string $name
   *   The name of the setting to return.
   * @param mixed $default
   *   (optional) The default value to use if this setting is not set.
   *
   * @return mixed
   *   The value of the setting, the provided default if not set.
   */
  public function get($name, $default = NULL) {
    return isset($this->settings[$name]) ? $this->settings[$name] : $default;
  }

  /**
   * Returns all Memcache settings.
   *
   * @return array
   *   All settings.
   */
  public function getAll() {
    return $this->settings;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MemcacheSettings::$settings protected property Array with the settings.
MemcacheSettings::get public function Returns a memcache setting.
MemcacheSettings::getAll public function Returns all Memcache settings.
MemcacheSettings::__construct public function Constructor.