3 * @copyright Copyright (C) 2020, Friendica
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Core\Lock;
24 use Friendica\Core\Cache\Duration;
32 * Checks, if a key is currently locked to a or my process
34 * @param string $key The name of the lock
38 public function isLocked($key);
42 * Acquires a lock for a given name
44 * @param string $key The Name of the lock
45 * @param integer $timeout Seconds until we give up
46 * @param integer $ttl Seconds The lock lifespan, must be one of the Cache constants
48 * @return boolean Was the lock successful?
50 public function acquire($key, $timeout = 120, $ttl = Duration::FIVE_MINUTES);
53 * Releases a lock if it was set by us
55 * @param string $key The Name of the lock
56 * @param bool $override Overrides the lock to get released
58 * @return boolean Was the unlock successful?
60 public function release($key, $override = false);
63 * Releases all lock that were set by us
65 * @param bool $override Override to release all locks
67 * @return boolean Was the unlock of all locks successful?
69 public function releaseAll($override = false);
72 * Returns the name of the current lock
76 public function getName();
81 * @param string prefix optional a prefix to search
83 * @return array Empty if it isn't supported by the cache driver
85 public function getLocks(string $prefix = '');