memcached 连接池 java_【memcached】中的连接池初始化

本文介绍了Java中使用SchoonerSockIOPool作为memcached连接池的初始化过程,包括ConcurrentMap `pools` 的作用,初始化函数的关键步骤,如检查服务器配置、创建Socket连接以及`populateConsistentBuckets`和`populateBuckets`的区别。同时提到了可能存在的重复初始化问题以及Socket工厂类AuthSchoonerSockIOFactory和SchoonerSockIOFactory。
摘要由CSDN通过智能技术生成

在memcached中的连接池,是com.schooner.MemCached.SchoonerSockIOPool

在SchoonerSockIOPool中,

// store instances of pools

private static ConcurrentMap pools = new ConcurrentHashMap();

pools保存目前所有SchoonerSockIOPool,是个ConcurrentMap对象;key=poolName,value=Pool;

缺省的名字叫做default;

在设置好服务器后,需要调用初始化函数:

/**

* Initializes the pool.

*/

public void initialize() {

initDeadLock.lock();

try {

// if servers is not set, or it empty, then

// throw a runtime exception

if (servers == null || servers.length <= 0) {

log.error("++++ trying to initialize with no servers");

throw new IllegalStateException("++++ trying to initialize with no servers");

}

// pools

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值