DELETE FROM records
WHERE
    downloads >= max_downloads
    OR julianday('now') - julianday(uploaded) > 3
RETURNING cache_name;
