用ThreadLocal支持分布式单点登陆吗?ThreadLocal比redis好吗。
//使用ThreadLocal,可以隔离每个线程的数据,为每一个线程创建数据副本,各个用户的数据不会混乱
private static ThreadLocal<Map<String,Object>> threadLocal = new ThreadLocal<>();
//设置user值
public static void set(User user,Integer scope){
// LocalUser.user = user;
Map<String,Object> map = new HashMap<>();
map.put("user",user);
map.put("scope",scope);
//把包含用户信息和权限的HashMap,保存到threadLocal中
LocalUser.threadLocal.set(map);
}