cache: add a check for a failed allocation Rather minimal change, but it's the kind of thing we should do.