コード例 #1
0
 /**
  * reloads proxy list.
  *
  * "fresh" has two meanings in this context
  * - proxies not used withing last $max_age seconds
  * - one new proxy which will be loaded from the api (if reload limit is not violated)
  */
 public function getFreshProxies($max_age = 20)
 {
     $now = time();
     //@todo: change false and null. same for CSVAdapter
     if ($max_age === false) {
         $max_age = $now;
     }
     // try to load new one
     $this->loadFreshProxy();
     $proxies = new LinkedQueue();
     $iterator = $this->proxies->getIterator();
     while ($iterator->valid()) {
         $proxy = $iterator->current();
         if (false === $max_age || $proxy->getLastUsed() < $now - $max_age) {
             $proxies->enqueue($proxy);
         }
         $iterator->next();
     }
     return $proxies;
 }
コード例 #2
0
 public function getFreshProxies($timetowait = false)
 {
     $proxies = new LinkedQueue();
     $now = time();
     $iterator = $this->proxies->getIterator();
     while ($iterator->valid()) {
         $proxy = $iterator->current();
         if (false === $timetowait || $proxy->getLastUsed() < $now - $timetowait) {
             $proxies->enqueue($proxy);
         }
         $iterator->next();
     }
     return $proxies;
 }