Rename RelationshipVortex to RelationshipCache
[civicrm-core.git] / Civi / Core / Lock / NullLock.php
CommitLineData
10760fa1
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
41498ac5 4 | Copyright CiviCRM LLC. All rights reserved. |
10760fa1 5 | |
41498ac5
TO
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
10760fa1
TO
9 +--------------------------------------------------------------------+
10 */
11namespace Civi\Core\Lock;
12
13/**
14 *
15 * @package CRM
ca5cec67 16 * @copyright CiviCRM LLC https://civicrm.org/licensing
10760fa1
TO
17 */
18class NullLock implements LockInterface {
19
20 private $hasLock = FALSE;
21
22 /**
b8c71ffa 23 * Create lock.
24 *
10760fa1 25 * @param string $name
b8c71ffa 26 *
10760fa1
TO
27 * @return static
28 */
29 public static function create($name) {
30 return new static();
31 }
32
33 /**
b8c71ffa 34 * Acquire lock.
35 *
e97c66ff 36 * @param int|null $timeout
10760fa1
TO
37 * The number of seconds to wait to get the lock.
38 * For a default value, use NULL.
b8c71ffa 39 *
10760fa1
TO
40 * @return bool
41 */
42 public function acquire($timeout = NULL) {
43 $this->hasLock = TRUE;
44 return TRUE;
45 }
46
47 /**
b8c71ffa 48 * Release lock.
49 *
10760fa1
TO
50 * @return bool|null|string
51 * Trueish/falsish.
52 */
53 public function release() {
54 $this->hasLock = FALSE;
55 return TRUE;
56 }
57
58 /**
59 * @return bool|null|string
60 * Trueish/falsish.
61 * @deprecated
62 * Not supported by some locking strategies. If you need to poll, better
63 * to use acquire(0).
64 */
65 public function isFree() {
66 return !$this->hasLock;
67 }
68
69 /**
70 * @return bool
71 */
72 public function isAcquired() {
73 return $this->hasLock;
74 }
75
76}