我正在使用 Jedis 与 REST 服务中的 Redis 服务器连接。
当我调用网络服务时,我想做这样的操作jedis.hmget , jedis.退出 and hgetALL.
例如:
jedis.hmget("employee:data:" + emp_user_id, "employee_id").get(0);
我用于 Redis 的配置是:
Jedis jedis;
JedisShardInfo shardInfo;
@PostConstruct
public void init() {
try {
shardInfo = new JedisShardInfo(Config.getRedisHost(), Config.getRedisPort());
shardInfo.setPassword(Config.getRedisPassword());
jedis = new Jedis(shardInfo);
jedis.select(2);
//jedis.se
} catch (Exception e) {
logger.error("Exception in init ------- > " + e);
}
}
我知道 Jedis 不是线程安全的。当我同时使用 1000 个线程调用服务时,我收到一个异常,即流的意外结束。我想知道Jedis池是线程安全的吗?无法找到具体的解决方案。
谢谢。任何帮助,将不胜感激。
JedisPool pool = new JedisPool(new JedisPoolConfig(), "localhost", portno, 10000,
"password");
看这里:https://github.com/xetorthio/jedis/wiki/Getting-started
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)