Spring Boot: Caching

preview_player
Показать описание
In this video we will understand Spring Boot Caching concepts. We will see how to enable caching and customize our caching strategy with the various caching annotations spring provides.
You ca download the source code for the project at the following github url:
Рекомендации по теме
Комментарии
Автор

Done thanks
Cacheable by default uses the method params as key for the cache. Can specify a custom key (if we want to cache based on another key)
5:40 how to specify your own key. #root gives top level access where we can get the method name and args
6:30 @cacheput ensures that method is always executed (value not returned from the cache) use it for methods that update the cache (without cacheput we would return the existing cache hit. Cacheput updates the cache for a given key - cache would be out of date if we don’t do that) it takes the name of the cache we want to update and which param to use as key
Annotating add and update functions with @cacheput
Annotating delete functions with @cacheevict, can remove specific keys or all keys
10:40 cache based on condition
11:28 unless condition for cache (unless means do NOT cache it condition is true)
12:00 Unless uses #result which is the returned value, so unless condition is evaluated AFTER the method runs, we then decide if we want to cache this returned value or not. But the condition part of the annotation is evaluated here before the method runs, based on parameters passed to the method

mostinho
Автор

With in 13 mnts you gave maximum information, its very helpful thanks

veligarampremkumar
Автор

Is it possible to add cache expiry time if you are using @Cacheable ?

sompamalakar
Автор

Hi, I'm getting an error saying "cannot find symbol key" when I try to set key value. I'm not sure what I am missing here.

randomguyzsz
Автор

Hello, is it possible to save List of Person (while using getAll()method) in cache by theirs Id? Because where you call getAll(), then update one of Person, and again call getAll(), then you get List of Person as there was no update (as in your first call of getAll()).

arekszyszkowski
welcome to shbcf.ru