DmitryDulepov\Realurl\Cache\DatabaseCache::limitTableRecords PHP Method

limitTableRecords() protected method

Records are removed in the uid order (oldest first). This is not a true clean up, which would be based on the last access timestamp but good enough to maintain performance.
protected limitTableRecords ( string $tableName ) : boolean
$tableName string
return boolean
    protected function limitTableRecords($tableName)
    {
        $cleanedUp = false;
        if (mt_rand(0, mt_getrandmax()) % 5 == 0) {
            $this->databaseConnection->sql_query('DELETE FROM ' . $tableName . ' WHERE uid <= (SELECT t2.uid FROM (SELECT uid FROM ' . $tableName . ' ORDER BY uid DESC LIMIT ' . self::$maximumNumberOfRecords . ',1) t2)');
            $cleanedUp = $this->databaseConnection->sql_affected_rows() > 0;
        }
        return $cleanedUp;
    }