Cache: use a database transition for scanning each folder

gives a massive speed improvement while scanning files