package com .test .log .makefriends
import redis .clients .jedis .{ JedisPool , JedisPoolConfig }
import scala .collection .mutable .ArrayBuffer
/**
* @Author: jxx
* @Date: 2018/3/27 16:28
*/
object RedisUtil extends Serializable {
def redisUtil (data: ArrayBuffer [ Array [ Byte ]]): java .util . ArrayList [ AnyRef ] = {
var pool: JedisPool = null
if (pool == null ) {
val config = new JedisPoolConfig ()
config .setMaxTotal ( 96 )
config .setMaxIdle ( 64 )
config .setMaxWaitMillis ( 30000 )
config .setTestOnBorrow ( false )
pool = new JedisPool (config , "localhost" , port )
}
val jedis = pool .getResource
try {
val sids = new java .util .ArrayList [ AnyRef ]
for (key <- data ) sids .add (jedis .get (key ))
sids
} catch {
case _: Exception => null
} finally {
pool .close ()
}
}
} |