public static function LockMemcache::reLock in Ultimate Cron 8.2
Relock.
Parameters
string $lock_id: The lock id to relock.
float $timeout: The timeout in seconds for the lock.
Return value
boolean TRUE if relock was successful.
File
- src/
Lock/ LockMemcache.php, line 138
Class
- LockMemcache
- Class for handling lock functions.
Namespace
Drupal\ultimate_cron\LockCode
public static function reLock($lock_id, $timeout = 30.0) {
if (!preg_match('/(.*):memcache-lock.*/', $lock_id, $matches)) {
return FALSE;
}
$name = $matches[1];
if (!($semaphore = self::lock("lock-{$name}"))) {
return FALSE;
}
$bin = variable_get('ultimate_cron_lock_memcache_bin', 'semaphore');
$current_lock_id = self::isLocked($name);
if ($current_lock_id === FALSE || $current_lock_id === $lock_id) {
if (dmemcache_set($name, $lock_id, $timeout, $bin)) {
self::unlockRaw("lock-{$name}", $semaphore);
self::$locks[$lock_id] = TRUE;
return self::$locks[$lock_id];
}
}
self::unlockRaw("lock-{$name}", $semaphore);
return FALSE;
}