X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FLock%2FCacheLockDriver.php;h=69db1c27f83c7e5fcc679fc661ce2f2d34196ad4;hb=86bf2ee45a7c7409dbc470b5b1706b19e7e40507;hp=c1cd8ffb43a3ab407324c757e2cbd0190737ed75;hpb=4e3f780621d991e5e619cee7fb15a2d919a3eb19;p=friendica.git diff --git a/src/Core/Lock/CacheLockDriver.php b/src/Core/Lock/CacheLockDriver.php index c1cd8ffb43..69db1c27f8 100644 --- a/src/Core/Lock/CacheLockDriver.php +++ b/src/Core/Lock/CacheLockDriver.php @@ -3,21 +3,21 @@ namespace Friendica\Core\Lock; use Friendica\Core\Cache; -use Friendica\Core\Cache\IMemoryCacheDriver; +use Friendica\Core\Cache\IMemoryCache; -class CacheLockDriver extends AbstractLockDriver +class CacheLockDriver extends AbstractLock { /** - * @var \Friendica\Core\Cache\ICacheDriver; + * @var \Friendica\Core\Cache\ICache; */ private $cache; /** * CacheLockDriver constructor. * - * @param IMemoryCacheDriver $cache The CacheDriver for this type of lock + * @param IMemoryCache $cache The CacheDriver for this type of lock */ - public function __construct(IMemoryCacheDriver $cache) + public function __construct(IMemoryCache $cache) { $this->cache = $cache; } @@ -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); @@ -66,11 +66,13 @@ class CacheLockDriver extends AbstractLockDriver $cachekey = self::getLockKey($key); if ($override) { - $this->cache->delete($cachekey); + $return = $this->cache->delete($cachekey); } else { - $this->cache->compareDelete($cachekey, getmypid()); + $return = $this->cache->compareDelete($cachekey, getmypid()); } $this->markRelease($key); + + return $return; } /** @@ -79,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; } }