It's faster without locks, gnarl ...

This commit is contained in:
Michael 2017-06-12 19:20:50 +00:00
commit 1301a29505
2 changed files with 3 additions and 15 deletions

View file

@ -57,7 +57,6 @@ class Lock {
$memcache = self::connectMemcache();
if (is_object($memcache)) {
$wait_sec = 0.2;
$cachekey = get_app()->get_hostname().";lock:".$fn_name;
do {
@ -82,15 +81,13 @@ class Lock {
dba::unlock();
if (!$got_lock && ($timeout > 0)) {
usleep($wait_sec * 1000000);
usleep(rand(10000, 200000));
}
} while (!$got_lock && ((time() - $start) < $timeout));
return $got_lock;
}
$wait_sec = 2;
do {
dba::lock('locks');
$lock = dba::select('locks', array('locked', 'pid'), array('name' => $fn_name), array('limit' => 1));
@ -118,7 +115,7 @@ class Lock {
dba::unlock();
if (!$got_lock && ($timeout > 0)) {
sleep($wait_sec);
usleep(rand(100000, 2000000));
}
} while (!$got_lock && ((time() - $start) < $timeout));