-
Notifications
You must be signed in to change notification settings - Fork 0
Caching
Mohammad Badar Hashimi edited this page Jan 18, 2020
·
1 revision
By annotating the method using the @Cacheable annotation the result of the subsequent invocations will be cached. The @CacheEvict(allEntries=true) clears all the entries from the cache.
@Cachable
Is used to adding the cache behavior to a method. We can also give the name to it, where the cache results would be saved.
@CacheEvict
Is used to remove the one or more cached values. allEntries=true parameter allows us to remove all entries from the cache.
@CachePut
Is used to update the cached value. Creating an Item model
@Cacheable(value="itemCache", key="#id")
public Item getItem(int id){
}
@CacheEvict(value="itemCache",key = "#id")
public int deleteItem(int id){
}
@CachePut(value="itemCache")
public void updateItem(Item item){
}