X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/e03ae6d7ebdf56d084b00091382f5bcf0cb7e486..274f38105249c24d355b1f46749c3841ffff6ff0:/lib/lib.php diff --git a/lib/lib.php b/lib/lib.php index 20f5af17..91fe21b2 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -919,9 +919,14 @@ function getBucketMemcache() { + static $m; + if (!CONST_ConnectionBucket_MemcacheServerAddress) return null; - $m = new Memcached(); - $m->addServer(CONST_ConnectionBucket_MemcacheServerAddress, CONST_ConnectionBucket_MemcacheServerPort); + if (!isset($m)) + { + $m = new Memcached(); + $m->addServer(CONST_ConnectionBucket_MemcacheServerAddress, CONST_ConnectionBucket_MemcacheServerPort); + } return $m; } @@ -994,6 +999,15 @@ return $iMaxVal; } + function byLastBlockTime($a, $b) + { + if ($a['lastBlockTimestamp'] == $b['lastBlockTimestamp']) + { + return 0; + } + return ($a['lastBlockTimestamp'] > $b['lastBlockTimestamp']) ? -1 : 1; + } + function getBucketBlocks() { $m = getBucketMemcache(); @@ -1014,6 +1028,7 @@ 'currentlyBlocked' => $iCurrentBucketSize + (CONST_ConnectionBucket_Cost_Reverse) >= CONST_ConnectionBucket_BlockLimit, ); } + uasort($aBlockedList, 'byLastBlockTime'); return $aBlockedList; }