1、先确保jmeter引入redis
import redis.clients.jedis.Jedis;
public static String getValue(){
String data = "${i-code}";
String redis_ip = "172.16.64.6";
int port = 6379;
Jedis jedis = new Jedis(redis_ip,port);
jedis.auth("zD6MovvH6XO4Hfg");
jedis.select(0);
String key = "jiajiao_manage_token_"+data;
String value = jedis.get(key);
return value;
}
String redis_token = getValue();
if(redis_token !=null){
Failure = false;
}else{
Failure = true;
FailureMessage="redis未找到预期的数据!"+
"redis返回:redis_token="+redis_token+";";
}