]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/lib.php
if doing structured query limit the types of osm place returned
[nominatim.git] / lib / lib.php
index 20f5af17787c7386cd98594f74c1e5c30198ead5..91fe21b2c79626b23f087387a1dfb95d0c2bca16 100644 (file)
 
        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;
        }
 
                return $iMaxVal;
         }
 
+       function byLastBlockTime($a, $b)
+       {
+               if ($a['lastBlockTimestamp'] == $b['lastBlockTimestamp'])
+               {
+                       return 0;
+               }
+               return ($a['lastBlockTimestamp'] > $b['lastBlockTimestamp']) ? -1 : 1;
+       }
+
        function getBucketBlocks()
        {
                $m = getBucketMemcache();
                                'currentlyBlocked' => $iCurrentBucketSize + (CONST_ConnectionBucket_Cost_Reverse) >= CONST_ConnectionBucket_BlockLimit,
                                );
                }
+               uasort($aBlockedList, 'byLastBlockTime');
                return $aBlockedList;
        }