cache: avoid some crashes

It's actually possible to start queries without any cache open,
e.g. add `resolve('.', kres.type.DNSKEY)` into your configuration.
If that happens, avoid the cache module dereferencing a NULL pointer.
26 jobs for nitpicks
in 60 minutes and 51 seconds and was queued for 5 seconds