File tree Expand file tree Collapse file tree
spring-boot/cache/src/main/java/io/reflectoring/cache/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,12 +25,12 @@ public Car saveCar(Car car) {
2525 return carRepository .save (car );
2626 }
2727
28- @ CachePut (value = "cars" )
28+ @ CachePut (value = "cars" , key = "#car.id" )
2929 public Car update (Car car ) {
3030 if (carRepository .existsById (car .getId ())) {
3131 return carRepository .save (car );
3232 }
33- throw new IllegalArgumentException ("A car mus have an id to be updated" );
33+ throw new IllegalArgumentException ("A car must have an id to be updated" );
3434 }
3535
3636 @ Cacheable (value = "cars" )
@@ -39,7 +39,7 @@ public Car get(UUID uuid) {
3939 .orElseThrow (() -> new IllegalStateException ("car with id " + uuid + " was not found" ));
4040 }
4141
42- @ CacheEvict (value = "cars" )
42+ @ CacheEvict (value = "cars" , key = "#uuid" )
4343 public void delete (UUID uuid ) {
4444 carRepository .deleteById (uuid );
4545 }
You can’t perform that action at this time.
0 commit comments