| @@ 115-128 (lines=14) @@ | ||
| 112 | * @param int|null $workerID |
|
| 113 | * @return bool |
|
| 114 | */ |
|
| 115 | private function markAsActive($base, $workerID = 0) |
|
| 116 | { |
|
| 117 | if ($workerID == 0) { |
|
| 118 | $query = $this->pdo->prepare(<<<SQL |
|
| 119 | UPDATE robotstxt__cache1 |
|
| 120 | SET worker = NULL |
|
| 121 | WHERE base = :base AND worker = 0; |
|
| 122 | SQL |
|
| 123 | ); |
|
| 124 | $query->bindParam(':base', $base, PDO::PARAM_STR); |
|
| 125 | return $query->execute(); |
|
| 126 | } |
|
| 127 | return true; |
|
| 128 | } |
|
| 129 | ||
| 130 | /** |
|
| 131 | * Update an robots.txt in the database |
|
| @@ 313-323 (lines=11) @@ | ||
| 310 | * @param int $delay - in seconds |
|
| 311 | * @return bool |
|
| 312 | */ |
|
| 313 | public function clean($delay) |
|
| 314 | { |
|
| 315 | $delay = self::CACHE_TIME + $delay; |
|
| 316 | $query = $this->pdo->prepare(<<<SQL |
|
| 317 | DELETE FROM robotstxt__cache1 |
|
| 318 | WHERE (worker = 0 OR worker IS NULL) AND nextUpdate < (UNIX_TIMESTAMP() - :delay); |
|
| 319 | SQL |
|
| 320 | ); |
|
| 321 | $query->bindParam(':delay', $delay, PDO::PARAM_INT); |
|
| 322 | return $query->execute(); |
|
| 323 | } |
|
| 324 | } |
|
| 325 | ||
| @@ 39-48 (lines=10) @@ | ||
| 36 | * @param int $delay - in seconds |
|
| 37 | * @return bool |
|
| 38 | */ |
|
| 39 | public function clean($delay = 60) |
|
| 40 | { |
|
| 41 | $query = $this->pdo->prepare(<<<SQL |
|
| 42 | DELETE FROM robotstxt__delay0 |
|
| 43 | WHERE delayUntil < ((UNIX_TIMESTAMP() - :delay) * 1000000); |
|
| 44 | SQL |
|
| 45 | ); |
|
| 46 | $query->bindParam(':delay', $delay, PDO::PARAM_INT); |
|
| 47 | return $query->execute(); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * Top X wait time |
|