refactoring: factor out code for cache dropping