NullLockBackend.php 1.29 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php

/**
 * @file
 * Definition of Drupal\Core\Lock\NullLockBackend.
 */

namespace Drupal\Core\Lock;

/**
 * Defines a Null lock backend.
 *
 * This implementation won't actually lock anything and will always succeed on
 * lock attempts.
15
16
 *
 * @ingroup lock
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 */
class NullLockBackend implements LockBackendInterface {

  /**
   * Current page lock token identifier.
   *
   * @var string
   */
  protected $lockId;

  /**
   * Implements Drupal\Core\Lock\LockBackedInterface::acquire().
   */
  public function acquire($name, $timeout = 30.0) {
    return TRUE;
  }

  /**
   * Implements Drupal\Core\Lock\LockBackedInterface::lockMayBeAvailable().
   */
  public function lockMayBeAvailable($name) {
    return TRUE;
  }

  /**
   * Implements Drupal\Core\Lock\LockBackedInterface::wait().
   */
  public function wait($name, $delay = 30) {}

  /**
   * Implements Drupal\Core\Lock\LockBackedInterface::release().
   */
  public function release($name) {}

  /**
   * Implements Drupal\Core\Lock\LockBackedInterface::releaseAll().
   */
  public function releaseAll($lock_id = NULL) {}

  /**
   * Implements Drupal\Core\Lock\LockBackedInterface::getLockId().
   */
  public function getLockId() {
    if (!isset($this->lockId)) {
      $this->lockId = uniqid(mt_rand(), TRUE);
    }
    return $this->lockId;
  }
}