@Caching(cacheable = { @Cacheable(cacheNames="smallBooks", condition="#name.length < 32"), @Cacheable(cacheNames="fiction", condition="#domain.equals('fiction')"), @Cacheable(cacheNames="everythingelse")})
public Book findBook(String name, String domain)
いいえ平行評価がない、@Cacheable
注釈は(キャッシュ可能性がやっぱ配列で)リンクされたコードに従ってgathered in the order of definitionを得ています。異なる名前と条件で3つのキャッシュを定義していることに気づくことが重要です。
私はここにあなたのユースケースを知らないのでSpring Caching Guideのわずかな変化である:
//..
@Override
@Caching(cacheable = {
@Cacheable(cacheNames = "sth"),
@Cacheable(cacheNames="everythingelse")
})
public Book getByIsbn(String isbn) {
simulateSlowService();
return new Book(isbn, "Some book");
}
//..
と春ブーツのapplication.properties
におけるキャッシュのパッケージでDEBUG
レベルを定義することによって:
logging.level.org.springframework.cache=DEBUG
別のキャッシュとして実際にどのようにロードされているかを確認できます。
2016-11-29 00:52:26.472 DEBUG 23426 --- [ main] o.s.c.a.AnnotationCacheOperationSource : Adding cacheable method 'getByIsbn' with attribute: [Builder[public hello.Book hello.SimpleBookRepository.getByIsbn(java.lang.String)] caches=[sth] | key='' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false', Builder[public hello.Book hello.SimpleBookRepository.getByIsbn(java.lang.String)] caches=[everythingelse] | key='' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false']