paulwong

MONGODB连接池

一般的WEB应用如果是连ORACLE,要做连接池的话是在JAVA端用第三方的LIB,但对于MONGODB,官方已经有现成的实现,只需配置即可。


#控制系统在发生连接错误时是否重试 ,默认为false --boolean 
mongo.options.autoConnectRetry=false 


#每个主机允许的连接数(每个主机的连接池大小),当连接池被用光时,会被阻塞住 ,默认为10 --int 
mongo.options.connectionsPerHost=10 


#multiplier for connectionsPerHost for # of threads that can block if connectionsPerHost is 10, and threadsAllowedToBlockForConnectionMultiplier is 5, then 50 threads can block more than that and an exception will be throw --int 
mongo.options.threadsAllowedToBlockForConnectionMultiplier=5 


#被阻塞线程从连接池获取连接的最长等待时间(ms) --int 
mongo.options.maxWaitTime 


#在建立(打开)套接字连接时的超时时间(ms),默认为0(无限) --int 
mongo.options.connectTimeout=0 


#套接字超时时间;该值会被传递给Socket.setSoTimeout(int)。默认为0(无限) --int 
mongo.options.socketTimeout=0 


#This controls whether or not to have socket keep alive turned on (SO_KEEPALIVE). defaults to false --boolean 
mongo.options.socketKeepAlive=false 


#Override the DBCallback factory. Default is for the standard Mongo Java driver configuration --DBCallbackFactory 
mongo.options.dbCallbackFactory 


#//指明是否允许驱动从次要节点或者奴隶节点读取数据,默认为false --boolean 
mongo.options.slaveOk=false 


#如果为true,驱动每次update后会发出一个getLastError命令来保证成功,默认为false --boolean 

mongo.options.safe=false 

#If set, the w value of WriteConcern for the connection is set to this. Defaults to 0; implies safe = true --int 
mongo.options.w=0 


#If set, the wtimeout value of WriteConcern for the connection is set to this. Defaults to 0; implies safe = true --int 
mongo.options.wtimeout=0 


#Sets the fsync value of WriteConcern for the connection. Defaults to false; implies safe = true --boolean 
mongo.options.fsync=false

posted on 2014-02-28 16:38 paulwong 阅读(1133) 评论(0)  编辑  收藏 所属分类: MONGODB


只有注册用户登录后才能发表评论。


网站导航: