1 つ以上のキャッシュにカスタムキャッシュマネージャーを使用できます。キャッシュマネージャープロデューサーにキャッシュ修飾子でアノテーションを付ける必要があります。以下の例を参照してください。
public class Config {
@GreetingCache
@Produces
@ApplicationScoped
public EmbeddedCacheManager specificEmbeddedCacheManager() {
return new DefaultCacheManager(new ConfigurationBuilder()
.expiration()
.lifespan(60000l)
.build());
}
@RemoteGreetingCache
@Produces
@ApplicationScoped
public RemoteCacheManager specificRemoteCacheManager() {
return new RemoteCacheManager("localhost", 1544);
}
}
public class Config {
@GreetingCache
@Produces
@ApplicationScoped
public EmbeddedCacheManager specificEmbeddedCacheManager() {
return new DefaultCacheManager(new ConfigurationBuilder()
.expiration()
.lifespan(60000l)
.build());
}
@RemoteGreetingCache
@Produces
@ApplicationScoped
public RemoteCacheManager specificRemoteCacheManager() {
return new RemoteCacheManager("localhost", 1544);
}
}
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
上記のコードでは、GreetingCache または RemoteGreetingCache は生成されたキャッシュマネージャーに関連付けられます。