Cache: fixed npe when clearing caches