Cache logic.