Code Duplication    Length = 10-14 lines in 3 locations

src/DelayHandler.php 1 location

@@ 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

src/Cache.php 2 locations

@@ 156-169 (lines=14) @@
153
     * @param int|null $workerID
154
     * @return bool
155
     */
156
    private function markAsActive($base, $workerID = 0)
157
    {
158
        if ($workerID == 0) {
159
            $query = $this->pdo->prepare(<<<SQL
160
UPDATE robotstxt__cache0
161
SET worker = NULL
162
WHERE base = :base AND worker = 0;
163
SQL
164
            );
165
            $query->bindParam(':base', $base, PDO::PARAM_STR);
166
            return $query->execute();
167
        }
168
        return true;
169
    }
170
171
    /**
172
     * Update an robots.txt in the database
@@ 306-316 (lines=11) @@
303
     * @param int $delay - in seconds
304
     * @return bool
305
     */
306
    public function clean($delay = 600)
307
    {
308
        $delay = self::CACHE_TIME + $delay;
309
        $query = $this->pdo->prepare(<<<SQL
310
DELETE FROM robotstxt__cache0
311
WHERE worker = 0 AND nextUpdate < (UNIX_TIMESTAMP() - :delay);
312
SQL
313
        );
314
        $query->bindParam(':delay', $delay, PDO::PARAM_INT);
315
        return $query->execute();
316
    }
317
318
    /**
319
     * Invalidate cache