2.4. 缓存管理器配置 Beans
使用以下配置 Bean 自定义缓存管理器:
-
InfinispanRemoteConfigurer -
配置 -
InfinispanRemoteCacheCustomizer
注意
您只能创建一个 InfinispanRemoteConfigurer bean。但是,您可以使用其他 Bean 创建多个配置。
InfinispanRemoteConfigurer Bean
@Bean
public InfinispanRemoteConfigurer infinispanRemoteConfigurer() {
return () -> new ConfigurationBuilder()
.addServer()
.host("127.0.0.1")
.port(12345)
.build();
}
配置 Bean
@Bean
public org.infinispan.client.hotrod.configuration.Configuration customConfiguration() {
new ConfigurationBuilder()
.addServer()
.host("127.0.0.1")
.port(12345)
.build();
}
InfinispanRemoteCacheCustomizer Bean
@Bean
public InfinispanRemoteCacheCustomizer customizer() {
return b -> b.tcpKeepAlive(false);
}
提示
使用 @Ordered 注释以特定顺序应用自定义器。