Backend Development
Spring Boot
Subjective
Oct 03, 2025
How do you implement caching in Spring Boot?
Detailed Explanation
Enable caching with @EnableCaching:\n\n@EnableCaching\n@SpringBootApplication\npublic class Application { }\n\n@Service\npublic class UserService {\n @Cacheable("users")\n public User findById(Long id) {\n return userRepository.findById(id);\n }\n \n @CacheEvict("users")\n public void deleteUser(Long id) {\n userRepository.deleteById(id);\n }\n}
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts