Following @Cacheable annotation
@Cacheable(value="books", key="#isbn")
public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed)
- looks up in the cache based on the key
- if found return the result from cache
- if not found evaluates method
- updates the cache
- return the result
So that next time this method is called with same arguments it will be fetched from cache.
What I want instead is just to
- Look up in the cache based on key
- if found return the result from cache
- if not found return null
I don't want to update the cache in case of cache-miss, is there any way to do this using spring Annotation
@Cacheableannotation, and it's not really a common use case at all, so I'd guess that no you can't do this with spring annotations, and that you'll have to write afindBookInCache(ISBN isbn)method yourself. - beerbajay