1.下載jedis-2.2.1.jar,commons-pool-1.6.jar 兩個jar包放到jmeter lib文件下,重啓jmeterredis
2.添加Bean Shell Sampler,寫入腳本,截圖中爲參數化了apache
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,指定區緩存已清理緩存