ENH: Use a temporary directory for caching

If prefix/LOCAL-REPO is not writable, we use a temporary directory for
caching.
Add a warning for the user when the cache directory is not writable.