summaryrefslogtreecommitdiffstatshomepage
path: root/core/lib/Drupal/Core/Lock/NullLockBackend.php
blob: ad3be11f2c2b25d6ed0330c012e1d20e87f96c18 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
<?php

namespace Drupal\Core\Lock;

/**
 * Defines a Null lock backend.
 *
 * This implementation won't actually lock anything and will always succeed on
 * lock attempts.
 *
 * @ingroup lock
 */
class NullLockBackend implements LockBackendInterface {

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

  /**
   * {@inheritdoc}
   */
  public function acquire($name, $timeout = 30.0) {
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function lockMayBeAvailable($name) {
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function wait($name, $delay = 30) {}

  /**
   * {@inheritdoc}
   */
  public function release($name) {}

  /**
   * {@inheritdoc}
   */
  public function releaseAll($lock_id = NULL) {}

  /**
   * {@inheritdoc}
   */
  public function getLockId() {
    if (!isset($this->lockId)) {
      $this->lockId = uniqid((string) mt_rand(), TRUE);
    }
    return $this->lockId;
  }

}