1.单点登录:很多个系统,就比如你的一个账号登录了一个系统后,其他的项目可以直接进,登陆后会产生一个token(cookie),产生以后就会存在我们的redis上,然后去登陆其他的系统的时候,他是带这个cookie去请求的,然后他发现redis上已经有这个cookie了,而且是有效的,所以他是让他登录的;
2.redis:6379
mysql:3306
tomcat:8080
:MongoDB:27019
3.为了防止可以多个环境,我们一般用用户变量来添加
beanshell脚本:
import redis.clients.jedis.Jedis;
import java.util.ArrayList;
import org.apache.commons.lang3.StringUtils;
String host = "${redis-host}"; //服务器地址
int port = ${redis-port}; //端口号
String password = "${redis-password}"; //redis密码
int index = ${redis-index}; //redis db,0选择第一个db0
String key = "${redis-key}"; //key值
Jedis jedis = new Jedis(host, port);
if(StringUtils.isNotBlank(password)){
jedis.auth(password);
}
jedis.select(index);
String cont= jedis.get("name");//提取string类型的redis的key的value值;
vars.put("cont",cont);
// 添加String
//jedis.set("student", "jack");
//读取String
//String student= jedis.get("student");
//vars.put("stingstudent",student);
//添加list
//String[] list = new String[]{"80","90","100"};
//jedis.lpush("scores",list);
//读取list
//List age =jedis.lrange("age",0,-1);
//log.info("------age----------"+age);
//添加set
//String[] list = new String[]{"Chinese","English","Math"};
//jedis.sadd("setcourse",list);
//读取set
//String colour = jedis.smembers("colour").toString();
//log.info("------colour----------"+colour);
//添加hash
//jedis.hset("hashstudents", "id", "1");
//jedis.hset("hashstudents", "name", "tracy");
//读取hash
//String hashkeys = jedis.hkeys("hashstudents").toString();
//log.info("------hashkeys----------"+hashkeys);
//String hsid = jedis.hget("hashstudents","id");
//log.info("------hsid----------"+hsid);
//String hsname = jedis.hget("hashstudents","name");
//log.info("------hsname----------"+hsname);
//添加zset
//jedis.zadd("zsetscore",80,"Chinese");
//jedis.zadd("zsetscore",90,"English");
//jedis.zadd("zsetscore",99,"Math");
//读取zset--读取每个科目
//String zsetscore = jedis.zrange("zsetscore", 0, -1).toString();
//log.info("------zsetscore----------"+zsetscore);
//读取zset--获取某个科目的分数
//String scores = jedis.zscore("zsetscore", "English").toString();
//log.info("------scores----------"+scores);
//删除
//jedis.del("student");