Holy crap, I forgot the break; in the switch statement at line ~27, and it built the cache then truncated the entire database :-0