Refactoring for better set/get cache