0
0
Spring Bootframework~10 mins

@Cacheable for read caching in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable caching on the method.

Spring Boot
@Cacheable(value = "books")
public Book [1](Long id) {
    // method body
}
Drag options to blanks, or click blank then click option'
AfindBookById
BgetBookById
CsaveBook
DdeleteBook
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method name that implies writing or deleting data.
Not matching the method name to the caching purpose.
2fill in blank
medium

Complete the annotation to specify the cache name.

Spring Boot
@Cacheable(value = "[1]")
public Book getBookById(Long id) {
    // method body
}
Drag options to blanks, or click blank then click option'
Abooks
Borders
Cusers
Dauthors
Attempts:
3 left
💡 Hint
Common Mistakes
Using a cache name unrelated to the method's data.
Using plural vs singular inconsistently.
3fill in blank
hard

Fix the error in the cache key expression.

Spring Boot
@Cacheable(value = "books", key = "#[1]")
public Book getBookById(Long id) {
    // method body
}
Drag options to blanks, or click blank then click option'
Aparam
BbookId
Ckey
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using a key that does not match any method parameter.
Forgetting the '#' symbol in the key expression.
4fill in blank
hard

Fill both blanks to create a cacheable method with a custom key.

Spring Boot
@Cacheable(value = "books", key = "#[1]")
public Book [2](Long bookId) {
    // method body
}
Drag options to blanks, or click blank then click option'
AbookId
BgetBook
CfindBook
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatch between key and parameter name.
Using a method name that implies writing data.
5fill in blank
hard

Fill all three blanks to define a cacheable method with a cache name, key, and method name.

Spring Boot
@Cacheable(value = "[1]", key = "#[2]")
public Book [3](Long id) {
    // method body
}
Drag options to blanks, or click blank then click option'
Aauthors
Bid
CgetBookById
Dbooks
Attempts:
3 left
💡 Hint
Common Mistakes
Using a cache name unrelated to the method.
Key not matching the parameter name.
Method name not indicating a read operation.