]> git.mxchange.org Git - friendica.git/blob - src/Core/Lock/ILockDriver.php
coding standards
[friendica.git] / src / Core / Lock / ILockDriver.php
1 <?php
2
3 namespace Friendica\Core\Lock;
4 use Friendica\Core\Cache;
5
6 /**
7  * Lock Driver Interface
8  *
9  * @author Philipp Holzer <admin@philipp.info>
10  */
11 interface ILockDriver
12 {
13         /**
14          * Checks, if a key is currently locked to a or my process
15          *
16          * @param string $key           The name of the lock
17          * @return bool
18          */
19         public function isLocked($key);
20
21         /**
22          *
23          * Acquires a lock for a given name
24          *
25          * @param string  $key      The Name of the lock
26          * @param integer $timeout  Seconds until we give up
27          * @param integer $ttl      Seconds The lock lifespan, must be one of the Cache constants
28          *
29          * @return boolean Was the lock successful?
30          */
31         public function acquireLock($key, $timeout = 120, $ttl = Cache::FIVE_MINUTES);
32
33         /**
34          * Releases a lock if it was set by us
35          *
36          * @param string $key The Name of the lock
37          *
38          * @return void
39          */
40         public function releaseLock($key);
41
42         /**
43          * Releases all lock that were set by us
44          *
45          * @return void
46          */
47         public function releaseAll();
48 }