ispan.client.hotrod.impl.transport.tcp.TcpTransportFactory
#infinispan.client.hotrod.transport_factory=
##序列化使用的Marshaller, default =org.infinispan.marshall.jboss.GenericJBossMarshaller
##如果要降低传输负载,可以配置为ApacheAvroMarshaller
#infinispan.client.hotrod.marshaller=
##指定自定义的AsyncExecutorFactory, default =org.infinispan.client.hotrod.impl.async.DefaultAsyncExecutorFactory
#infinispan.client.hotrod.async_executor_factory=
##指定并发线程池大小, default = 10
#infinispan.client.hotrod.default_executor_factory.pool_size=
##指定并发队列大小, default = 100000
#infinispan.client.hotrod.default_executor_factory.queue_size=
##Hash函数实现的版本及一致性Hash算法,和HotRod的服务器版本相关
#infinispan.client.hotrod.hash_function_impl.1=
##序列化和反序列化键的缓存允许字节数,目的是避免数组大小调整, default =64
#infinispan.client.hotrod.key_size_estimate=
##序列化和反序列化值的缓存允许字节数,目的是避免数组大小调整, default =512
#infinispan.client.hotrod.value_size_estimate=
##socket读超时, default = 60000 (60 seconds)
infinispan.client.hotrod.socket_timeout=50000
##socket连接超时, default = 60000 (60 seconds)
infinispan.client.hotrod.connect_timeout=10000
##指定客户端使用的协议版本, default = 1.1,其他值还有1.0
#infinispan.client.hotrod.protocol_version=
##指定错误时的重试次数, default = 10
#infinispan.client.hotrod.max_retries=
############连接池配置############
##指定每个服务器的最大连接数,负值表示没有限制,默认-1
maxActive=100
##指定服务器组内允许的全局持久连接的数量,负值表示没有限制,默认-1
maxTotal=100
##指定每个服务器空闲持久连接的最大数,负值表示没有限制,默认-1
maxIdle=20
##指定当连接池耗尽时,服务器如何响应:
##0-抛出异常给调用者
##1-阻塞调用者,直到有空闲的连接
##2-创建一个新的连接(不受maxActive的限制)
##默认值是1
#whenExhaustedAction=1
##检查空闲连接的Eviction线程每次运行间隔的时间,默认是2分钟
#timeBetweenEvictionRunsMillis=120000
##在空闲池中的连接存在多长时间需要被销毁,负值表示没有空闲连接被销毁,默认值为30分钟
#minEvictableIdleTimeMillis=1800000
##指定在Eviction线程执行时,空闲的连接是否通过发送一个TCP数据包到服务器来验证,
##即无法验证的连接将从池中被清除
##默认值为true
#testWhileIdle=true
##指定每个服务器最小的可用连接的空闲线程数。默认值为1
#minIdle=1
客户端访问代码
| import java.net.URL; import java.util.Map; import org.infinispan.client.hotrod.RemoteCache; import org.infinispan.client.hotrod.RemoteCacheManager; import org.infinispan.client.hotrod.ServerStatistics; public class Quickstart { public static void main(String[] args) { URL resource = Thread.currentThread().getContextClassLoader() .getResource("hotrod-client.properties"); RemoteCacheManager cacheContainer = new RemoteCacheManager(resource, true); //获得一个远程的Cache RemoteCache cache = cacheContainer.getCache("myCache"); //put数据到缓存中,然后确认是否存在 cache.put("name", "paul"); if(cache.get("name").equals("paul")){ System.out.println("Cache Hit!"); } else { System.out.println("Cache Miss!"); } //删除缓存数据 cache.remove("name"); cacheContainer.stop(); } } |