Refactor data storage in cache