| @@ 152-165 (lines=14) @@ | ||
| 149 | * @param int|null $workerID |
|
| 150 | * @return bool |
|
| 151 | */ |
|
| 152 | private function markAsActive($base, $workerID = 0) |
|
| 153 | { |
|
| 154 | if ($workerID == 0) { |
|
| 155 | $query = $this->pdo->prepare(<<<SQL |
|
| 156 | UPDATE robotstxt__cache0 |
|
| 157 | SET worker = NULL |
|
| 158 | WHERE base = :base AND worker = 0; |
|
| 159 | SQL |
|
| 160 | ); |
|
| 161 | $query->bindParam(':base', $base, PDO::PARAM_STR); |
|
| 162 | return $query->execute(); |
|
| 163 | } |
|
| 164 | return true; |
|
| 165 | } |
|
| 166 | ||
| 167 | /** |
|
| 168 | * Update an robots.txt in the database |
|
| @@ 302-312 (lines=11) @@ | ||
| 299 | * @param int $delay - in seconds |
|
| 300 | * @return bool |
|
| 301 | */ |
|
| 302 | public function clean($delay = 600) |
|
| 303 | { |
|
| 304 | $delay = self::CACHE_TIME + $delay; |
|
| 305 | $query = $this->pdo->prepare(<<<SQL |
|
| 306 | DELETE FROM robotstxt__cache0 |
|
| 307 | WHERE worker = 0 AND nextUpdate < (UNIX_TIMESTAMP() - :delay); |
|
| 308 | SQL |
|
| 309 | ); |
|
| 310 | $query->bindParam(':delay', $delay, PDO::PARAM_INT); |
|
| 311 | return $query->execute(); |
|
| 312 | } |
|
| 313 | } |
|
| 314 | ||
| @@ 57-66 (lines=10) @@ | ||
| 54 | * @param int $delay - in seconds |
|
| 55 | * @return bool |
|
| 56 | */ |
|
| 57 | public function clean($delay = 60) |
|
| 58 | { |
|
| 59 | $query = $this->pdo->prepare(<<<SQL |
|
| 60 | DELETE FROM robotstxt__delay0 |
|
| 61 | WHERE delayUntil < ((UNIX_TIMESTAMP() - :delay) * 1000000); |
|
| 62 | SQL |
|
| 63 | ); |
|
| 64 | $query->bindParam(':delay', $delay, PDO::PARAM_INT); |
|
| 65 | return $query->execute(); |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * Top X delays |
|