The short answer to your question is no. Cache annotations should be somewhat universal, while solutions to problems such as a thundering herd are implementation specific.
In the following comment, I assume that you are using Ehcache as an implementation. The page you linked to describes the problem, offers several solutions, for example, using BlockingCache as a decorator for the underlying cache. (The fact that they document such decisions implies that Ehcache, by default, does not cope with the thunder-herd problem.)
BlockingCache seems like the most straightforward solution, so I'll start with this. Using BlockingCache programmatically is quite simple, but using it by configuration requires a bit more work on your part. You will need to write your own BlockingCacheDecoratorFactory, expanding the Ehcache CacheDecoratorFactory. Once you do this, you can configure it in ehcache.xml for any cache it needs. But do this with caution; turning a cache into a BlockingCache useless can adversely affect performance.
Say you wrote your own factory decorator org.stacker.cache.BlockingCacheDecoratorFactory, and you have a cache named "adImages" that you want to protect from the thunder herd problem. Your new ehcache.xml entry might look like this:
<cache name="adImages" maxElementsInMemory="5000" eternal="false" timeToIdleSeconds="1800" timeToLiveSeconds="3600" overflowToDisk="false"> <cacheDecoratorFactory class="org.stacker.cache.BlockingCacheDecoratorFactory" /> </cache>
See the user guide http://ehcache.org/documentation/user-guide/cache-decorators to read about cache decorators in Ehcache. Hope this helps.
source share