cache: Improve _remove() function and fix crash with NULL passed