friendica/src/Core/Lock/ILockDriver.php

50 lines
1.0 KiB
PHP
Raw Normal View History

<?php
namespace Friendica\Core\Lock;
use Friendica\Core\Cache;
/**
* Lock Driver Interface
*
* @author Philipp Holzer <admin@philipp.info>
*/
interface ILockDriver
{
/**
2018-07-05 01:59:56 -04:00
* Checks, if a key is currently locked to a or my process
*
* @param string $key The name of the lock
* @return bool
*/
public function isLocked($key);
/**
*
2018-07-05 01:59:56 -04:00
* Acquires a lock for a given name
*
* @param string $key The Name of the lock
* @param integer $timeout Seconds until we give up
* @param integer $ttl Seconds The lock lifespan, must be one of the Cache constants
*
* @return boolean Was the lock successful?
*/
public function acquireLock($key, $timeout = 120, $ttl = Cache::FIVE_MINUTES);
/**
2018-07-05 01:59:56 -04:00
* Releases a lock if it was set by us
*
2019-02-24 04:08:28 -05:00
* @param string $key The Name of the lock
* @param bool $force Force the lock to get released
*
* @return void
*/
2019-02-24 04:08:28 -05:00
public function releaseLock($key, $force = false);
/**
2018-07-05 01:59:56 -04:00
* Releases all lock that were set by us
*
* @return void
*/
public function releaseAll();
2018-06-26 17:44:30 -04:00
}