public static function UltimateCronLockMemcache::reLock in Ultimate Cron 7.2
Relock.
Parameters
string $lock_id: The lock id to relock.
float $timeout: The timeout in seconds for the lock.
Return value
bool TRUE if relock was successful.
File
- ./
ultimate_cron.memcache-lock.inc, line 140 - A memcached-mediated implementation of a locking mechanism.
Class
- UltimateCronLockMemcache
- Class for handling lock functions.
Code
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;
}