Spark中访问Redis连接池的封装

package com.lg.blgdata.utils

import redis.clients.jedis.{Jedis, JedisPool, JedisPoolConfig}
import scala.collection.mutable.HashSet

//jedis连接池
object  JedisConnectionPool {
    //连接配置
    val config= new JedisPoolConfig()
    //最大连接数
    config.setMaxTotal(10)
    //最大空闲连接数
    config.setMaxIdle(3)
    //定期检测连接是否存在
    config.setTestOnBorrow(true)
    //设置连接池属性分别有: 配置  主机名   端口号  连接超时时间    Redis密码`
    val pool=new JedisPool(config,"192.168.x.xxx",6379,10000)
    
    //连接池
    def getConnections(): Jedis ={
      pool.getResource
    }
}