Created
April 14, 2020 10:52
-
-
Save PRASANTHRAJENDRAN/6bed0d589a1af556d0905b020b1b8fa8 to your computer and use it in GitHub Desktop.
Sample PhotoService with CRUD methods that uses spring boot caching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Service | |
| public class PhotoService { | |
| @CachePut(cacheNames = "photo", key = "#photo.id") | |
| public Photo createPhoto(Photo photo) { | |
| return photo; | |
| } | |
| @Cacheable(cacheNames = "photo", key = "#id") | |
| public Photo findById(String id) { | |
| return null; | |
| } | |
| @CachePut(cacheNames = "photo", key = "#id") | |
| public Photo updatePhoto(String id, Photo photo) { | |
| return photo; | |
| } | |
| @CacheEvict(cacheNames = "photo", key = "#id") | |
| public void deletePhoto(String id) { | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment