4 * @file src/Core/Lock.php
5 * @brief Functions for preventing parallel execution of functions
8 namespace Friendica\Core;
10 use Friendica\Core\Cache\Cache;
14 * This class contain Functions for preventing parallel execution of functions
19 * @brief Acquires a lock for a given name
21 * @param string $key Name of the lock
22 * @param integer $timeout Seconds until we give up
23 * @param integer $ttl The Lock lifespan, must be one of the Cache constants
25 * @return boolean Was the lock successful?
28 public static function acquire($key, $timeout = 120, $ttl = Cache::FIVE_MINUTES)
30 return DI::lock()->acquireLock($key, $timeout, $ttl);
34 * @brief Releases a lock if it was set by us
36 * @param string $key Name of the lock
37 * @param bool $override Overrides the lock to get releases
42 public static function release($key, $override = false)
44 return DI::lock()->releaseLock($key, $override);
48 * @brief Releases all lock that were set by us
52 public static function releaseAll()
54 DI::lock()->releaseAll();