hget和get redis_redis hget阻塞 使用redis时遇到的问题 - Redis - 服务器之家

redis hget阻塞 使用redis时遇到的问题

发布时间:2017-03-20

来源:服务器之家

1,redis 报异常

redis.clients.jedis.exceptions.JedisDataException: WRONGTYPE Operation against a key holding the wrong kind of value

@Test

public void test_faildTime(){

String identify="13718486139";

int failedTime=WapController.getFailedCount(identify);

System.out.println(failedTime);

}

/***

* 获取失败次数

* 限制IP

* @param httpSession

* @param request

* @param response

* @return

*/

public static int getFailedCount(String identify) {

int count = 0;

String retryString = RedisHelper.getInstance().getKeyCache(identify, "failCount");

if(!StringUtil.isNullOrEmpty(retryString)) {

count = new Integer(retryString).intValue();

}

System.out.println("getFailedCount\tcount:"+count);

return count;

}

原因:jedis.hget(id, k)的第一个参数(id)是"13718486139"

奇怪的是换成"23718486139"就好了,真是诡异

2,保存时设置超时时间

调用的是Jedis类中的:

/**

* Set the string value as

你可能感兴趣的:(hget和get,redis)