Maybe this will work, but I would suggest posting these annotations for implementation.
This is more of a theoretical question, but think of it this way: the interface is a common contract, but caching is an implementation detail .
Your interface can be implemented in several ways, for example, one day you can have an HsqlDBRepository, for which caching does not make sense at all, since it is already in memory.
On the side of the note, I would carefully think about why you need to βevict everyoneβ ... depending on how often this happens, this can make your caching useless - it is also often a sign of a deeper design problem. If you want to evict objects after a while, consider setting up timeToLive / timeToIdle - most cache backends support this beautifully.
source share