package com.sparkStreaming.day04
import java.util
import com.sparkStreaming.day04.JedisConnectionPool.client
import redis.clients.jedis._
object JedisConnectionPool {
val config = new JedisPoolConfig()
//最大连接数
config.setMaxTotal(20)
//最大空间连接数
config.setMaxIdle(10)
//当调用borrow Object方法时,是否进行有效性检查
config.setTestOnBorrow(true)
private val jedisCluster = new util.HashSet[HostAndPort]()
jedisCluster.add(new HostAndPort("192.168.12.11", 6378))
jedisCluster.add(new HostAndPort("192.168.12.11", 6379))
jedisCluster.add(new HostAndPort("192.168.12.12", 6378))
jedisCluster.add(new HostAndPort("192.168.12.12", 6379))
jedisCluster.add(new HostAndPort("192.168.12.13", 6378))
jedisCluster.add(new HostAndPort("192.168.12.13", 6379))
val client = new JedisCluster(jedisCluster)
//client.flushAll()
}
object RedisClient {
//val client = JedisConnectionPool.client
def incrby(key: String, value: Int) {
client.incrBy(key, value)
}
def set(key: String, value: Int) {
client.incrBy(key, value)
}
}