Refactor KeyCache