code refactoring about cache plugin