Skip to content

Instantly share code, notes, and snippets.

@PRASANTHRAJENDRAN
Created April 14, 2020 10:52
Show Gist options
  • Select an option

  • Save PRASANTHRAJENDRAN/6bed0d589a1af556d0905b020b1b8fa8 to your computer and use it in GitHub Desktop.

Select an option

Save PRASANTHRAJENDRAN/6bed0d589a1af556d0905b020b1b8fa8 to your computer and use it in GitHub Desktop.
Sample PhotoService with CRUD methods that uses spring boot caching
@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