You are here

class LockFactory in Redis 8

Lock backend singleton handling.

Hierarchy

Expanded class hierarchy of LockFactory

1 string reference to 'LockFactory'
redis.services.yml in ./redis.services.yml
redis.services.yml
1 service uses LockFactory
redis.lock.factory in ./redis.services.yml
Drupal\redis\Lock\LockFactory

File

src/Lock/LockFactory.php, line 10

Namespace

Drupal\redis\Lock
View source
class LockFactory {

  /**
   * @var \Drupal\redis\ClientInterface
   */
  protected $clientFactory;

  /**
   * Creates a redis LockFactory.
   */
  public function __construct(ClientFactory $client_factory) {
    $this->clientFactory = $client_factory;
  }

  /**
   * Get actual lock backend.
   *
   * @param bool $persistent
   *   (optional) Whether to return a persistent lock implementation or not.
   *
   * @return \Drupal\Core\Lock\LockBackendInterface
   *   Return lock backend instance.
   */
  public function get($persistent = FALSE) {
    $class_name = $this->clientFactory
      ->getClass($persistent ? ClientFactory::REDIS_IMPL_PERSISTENT_LOCK : ClientFactory::REDIS_IMPL_LOCK);
    return new $class_name($this->clientFactory);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LockFactory::$clientFactory protected property
LockFactory::get public function Get actual lock backend.
LockFactory::__construct public function Creates a redis LockFactory.