jmeter清理redis指定区缓存
1.下载jedis-2.2.1.jar,commons-pool-1.6.jar 两个jar包放到jmeter lib文件下,重启jmeter
2.添加Bean Shell Sampler,写入脚本,截图中为参数化了
import redis.clients.jedis.Jedis; import org.apache.commons.lang3.StringUtils; String host = "223.223.223.223"; //服务器地址 int port = 6379; //端口号 String password = "Rds@JnTEST123"; //redis密码 int index = 6; //redis db 缓存区 Jedis jedis = new Jedis(host, port); if(StringUtils.isNotBlank(password)){ jedis.auth(password); } jedis.select(index); //选择redis db String res = jedis.flushDB(); return res;
2.运行后查询redis,指定区缓存已清理