>>分享SPSS,Hadoop等大数据处理技术,以及分布式架构以及集群系统的构建 书籍支持  卫琴直播  品书摘要  在线测试  资源下载  联系我们
发表一个新主题 开启一个新投票 回复文章 您是本文章第 20069 个阅读者 刷新本主题
 * 贴子主题:  spark读取redis,连接池配置的范例代码 回复文章 点赞(0)  收藏  
作者:mary    发表时间:2020-03-21 16:01:46     消息  查看  搜索  好友  邮件  复制  引用

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 ()
      }
   }

}

----------------------------
原文链接:https://blog.csdn.net/jxx4903049/article/details/79733021

程序猿的技术大观园:www.javathinker.net



[这个贴子最后由 flybird 在 2020-03-21 16:01:46 重新编辑]
网站系统异常


系统异常信息
Request URL: http://www.javathinker.net/WEB-INF/lybbs/jsp/topic.jsp?postID=2942

java.lang.NullPointerException

如果你不知道错误发生的原因,请把上面完整的信息提交给本站管理人员