Mmmh... Shouldn't the key be a hash of the file content? Otherwise if the file is modified by another process, it's gonna be borked.