UPDATE records
SET downloads = downloads + 1
WHERE
    cache_name = ?
    AND downloads < max_downloads
    AND julianday('now') - julianday(uploaded) < 5;
