2018-06-26 20:31:04 +00:00
|
|
|
<?php
|
|
|
|
|
2018-06-28 20:57:17 +00:00
|
|
|
namespace Friendica\Core\Lock;
|
2018-06-26 20:31:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Lock Driver Interface
|
|
|
|
*
|
|
|
|
* @author Philipp Holzer <admin@philipp.info>
|
|
|
|
*/
|
|
|
|
interface ILockDriver
|
|
|
|
{
|
2018-07-04 21:37:22 +00:00
|
|
|
/**
|
2018-07-05 05:59:56 +00:00
|
|
|
* Checks, if a key is currently locked to a or my process
|
2018-07-04 21:37:22 +00:00
|
|
|
*
|
|
|
|
* @param string $key The name of the lock
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isLocked($key);
|
|
|
|
|
2018-06-26 20:31:04 +00:00
|
|
|
/**
|
|
|
|
*
|
2018-07-05 05:59:56 +00:00
|
|
|
* Acquires a lock for a given name
|
2018-06-26 20:31:04 +00:00
|
|
|
*
|
|
|
|
* @param string $key The Name of the lock
|
|
|
|
* @param integer $timeout Seconds until we give up
|
|
|
|
*
|
|
|
|
* @return boolean Was the lock successful?
|
|
|
|
*/
|
2018-07-05 18:57:31 +00:00
|
|
|
public function acquireLock($key, $timeout = 120);
|
2018-06-26 20:31:04 +00:00
|
|
|
|
|
|
|
/**
|
2018-07-05 05:59:56 +00:00
|
|
|
* Releases a lock if it was set by us
|
2018-06-26 20:31:04 +00:00
|
|
|
*
|
2018-06-28 20:57:17 +00:00
|
|
|
* @param string $key The Name of the lock
|
2018-06-26 20:31:04 +00:00
|
|
|
*
|
2018-06-28 20:57:17 +00:00
|
|
|
* @return void
|
2018-06-26 20:31:04 +00:00
|
|
|
*/
|
2018-07-05 18:57:31 +00:00
|
|
|
public function releaseLock($key);
|
2018-06-26 20:31:04 +00:00
|
|
|
|
|
|
|
/**
|
2018-07-05 05:59:56 +00:00
|
|
|
* Releases all lock that were set by us
|
2018-06-26 20:31:04 +00:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function releaseAll();
|
2018-06-26 21:44:30 +00:00
|
|
|
}
|