Make address caching more robust.

If looking up an address in the cache fails, make the function attempt
to resolve the bad ip address and return it if it can resolve it, only
failing if it can't truly be looked up.