0
0
Spring Bootframework~10 mins

@CachePut for updating cache 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 use @CachePut to update the cache after method execution.

Spring Boot
@CachePut(value = "users", key = "#user.id")
public User [1](User user) {
    // update user logic
    return user;
}
Drag options to blanks, or click blank then click option'
AdeleteUser
BgetUser
CupdateUser
DcreateUser
Attempts:
3 left
💡 Hint
Common Mistakes
Using @CachePut on a method that only retrieves data without updating.
Choosing a method name that does not indicate updating.
2fill in blank
medium

Complete the code to specify the cache key using SpEL expression in @CachePut.

Spring Boot
@CachePut(value = "products", key = "[1]")
public Product updateProduct(Product product) {
    // update logic
    return product;
}
Drag options to blanks, or click blank then click option'
Aid
B#product.id
C#id
Dproduct.id
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting '#' in the SpEL expression.
Using a variable name not matching the method parameter.
3fill in blank
hard

Fix the error in the @CachePut annotation to correctly update the cache for the method.

Spring Boot
@CachePut(value = "orders", key = "[1]")
public Order updateOrder(Order order) {
    // update order logic
    return order;
}
Drag options to blanks, or click blank then click option'
A#orderId
Border.id
CorderId
D#order.id
Attempts:
3 left
💡 Hint
Common Mistakes
Using a key expression without '#' symbol.
Referencing a variable name not declared as a parameter.
4fill in blank
hard

Fill both blanks to correctly use @CachePut with cache name and key expression.

Spring Boot
@CachePut(value = "[1]", key = "[2]")
public Customer updateCustomer(Customer customer) {
    return customer;
}
Drag options to blanks, or click blank then click option'
Acustomers
B#customer.id
C#id
Dusers
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong cache name that does not match the entity.
Incorrect key expression without '#' or wrong parameter name.
5fill in blank
hard

Fill all three blanks to create a method that updates cache with @CachePut, specifying cache name, key, and method name.

Spring Boot
@CachePut(value = "[1]", key = "[2]")
public Product [3](Product product) {
    // update logic
    return product;
}
Drag options to blanks, or click blank then click option'
Aproducts
B#product.id
CupdateProduct
DsaveProduct
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent cache names.
Incorrect key expressions missing '#'.
Method names that do not reflect updating.