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
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @brief Acquires a lock for a given name
|
|
|
|
*
|
|
|
|
* @param string $key The Name of the lock
|
|
|
|
* @param integer $timeout Seconds until we give up
|
|
|
|
*
|
|
|
|
* @return boolean Was the lock successful?
|
|
|
|
*/
|
2018-06-28 20:57:17 +00:00
|
|
|
public function acquireLock(string $key, int $timeout = 120);
|
2018-06-26 20:31:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Releases a lock if it was set by us
|
|
|
|
*
|
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-06-28 20:57:17 +00:00
|
|
|
public function releaseLock(string $key);
|
2018-06-26 20:31:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Releases all lock that were set by us
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function releaseAll();
|
2018-06-26 21:44:30 +00:00
|
|
|
}
|