How would you implement a caching mechanism to improve application performance in a distributed system?