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