You are here

class MemcachedBackendFactory in Memcache Storage 8

Hierarchy

Expanded class hierarchy of MemcachedBackendFactory

1 file declares its use of MemcachedBackendFactory
MemcacheStorageBackendUnitTest.php in src/Tests/MemcacheStorageBackendUnitTest.php
Contains \Drupal\memcache_storage\Tests\MemcacheStorageBackendUnitTest.
1 string reference to 'MemcachedBackendFactory'
memcache_storage.services.yml in ./memcache_storage.services.yml
memcache_storage.services.yml
1 service uses MemcachedBackendFactory
cache.backend.memcache_storage in ./memcache_storage.services.yml
Drupal\memcache_storage\MemcachedBackendFactory

File

src/MemcachedBackendFactory.php, line 8

Namespace

Drupal\memcache_storage
View source
class MemcachedBackendFactory {

  /**
   * @var \Drupal\Core\Site\Settings
   */
  protected $settings;

  /**
   * @var \Drupal\memcache_storage\DrupalMemcachedFactory
   */
  protected $memcachedFactory;

  /**
   * @var \Drupal\Core\Cache\CacheTagsChecksumInterface
   */
  protected $checksumProvider;

  /**
   * Constructs the MemcachedBackendFactory object.
   *
   * @param \Drupal\Core\Site\Settings $settings
   * @param \Drupal\memcache_storage\DrupalMemcachedFactory $memcached_factory
   * @param \Drupal\Core\Cache\CacheTagsChecksumInterface $checksum_provider
   */
  function __construct(DrupalMemcachedFactory $memcached_factory, Settings $settings, CacheTagsChecksumInterface $checksum_provider) {
    $this->settings = $settings;
    $this->memcachedFactory = $memcached_factory;
    $this->checksumProvider = $checksum_provider;
  }

  /**
   * Gets MemcacheBackend for the specified cache bin.
   *
   * @param $bin
   *   The cache bin for which the object is created.
   *
   * @return \Drupal\memcache_storage\MemcachedBackend
   *   The cache backend object for the specified cache bin.
   */
  public function get($bin) {

    // Prepopulate each cache bin name with the specific prefix to have a clear
    // and human readable cache bin names everywhere.
    $bin_name = 'cache_' . $bin;

    // Get DrupalMemcache or DrupalMemcached object for the specified bin.
    $memcached = $this->memcachedFactory
      ->get($bin_name);

    // Initialize a new object for a class that handles Drupal-specific part
    // of memcached cache backend.
    return new MemcachedBackend($bin_name, $memcached, $this->settings, $this->checksumProvider);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MemcachedBackendFactory::$checksumProvider protected property
MemcachedBackendFactory::$memcachedFactory protected property
MemcachedBackendFactory::$settings protected property
MemcachedBackendFactory::get public function Gets MemcacheBackend for the specified cache bin.
MemcachedBackendFactory::__construct function Constructs the MemcachedBackendFactory object.