Insert all elements of a returned list into a Cache [SPR-15213]
Closed this issue · 1 comments
Wouter Lievens opened SPR-15213 and commented
When a query method returns a list, I would like to be able to insert each element of that list separately into a Cache, each with its own associated key.
Reference URL: http://stackoverflow.com/questions/41966690/putting-all-returned-elements-into-a-spring-boot-cache-using-annotations
Stéphane Nicoll commented
Thanks for creating the issue but I am not keen to add this extra complexity to the cache abstraction. It is not meant to manage state for you (the next logical step if we allow this is that we have to keep the returned list in sync with each item). And if we don't we are inconsistent and we merely provide a way to talk to the cache using annotations. That's not very helpful.
Back to your example, this is typically what a second level cache is meant to do for you. This is not in the scope of the cache abstraction.