mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-08 00:04:27 +02:00
Refactor Cache/Lock to DICE
- Refactor Cache classes - Refactor Lock classes - Improved test speed (removed some seperate class annotations)
This commit is contained in:
parent
b95d4f41b9
commit
d56bd28a07
40 changed files with 766 additions and 621 deletions
|
@ -28,7 +28,7 @@ class CacheLockDriver extends AbstractLockDriver
|
|||
public function acquireLock($key, $timeout = 120, $ttl = Cache::FIVE_MINUTES)
|
||||
{
|
||||
$got_lock = false;
|
||||
$start = time();
|
||||
$start = time();
|
||||
|
||||
$cachekey = self::getLockKey($key);
|
||||
|
||||
|
@ -65,8 +65,6 @@ class CacheLockDriver extends AbstractLockDriver
|
|||
{
|
||||
$cachekey = self::getLockKey($key);
|
||||
|
||||
$return = false;
|
||||
|
||||
if ($override) {
|
||||
$return = $this->cache->delete($cachekey);
|
||||
} else {
|
||||
|
@ -83,15 +81,17 @@ class CacheLockDriver extends AbstractLockDriver
|
|||
public function isLocked($key)
|
||||
{
|
||||
$cachekey = self::getLockKey($key);
|
||||
$lock = $this->cache->get($cachekey);
|
||||
$lock = $this->cache->get($cachekey);
|
||||
return isset($lock) && ($lock !== false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key The original key
|
||||
* @return string The cache key used for the cache
|
||||
* @param string $key The original key
|
||||
*
|
||||
* @return string The cache key used for the cache
|
||||
*/
|
||||
private static function getLockKey($key) {
|
||||
private static function getLockKey($key)
|
||||
{
|
||||
return "lock:" . $key;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue