这个就是自己定义的一个东西吧
public Map<String,String> userLogin(String userName,String password){
Jedis jedis = null;
Map<String,String> result = new HashMap<String,String>();
User user = dao.fetch(User.class,Cnd.where("username","=",userName));
try { // JDK6的写法, 长长的try-finally
if(user==null){
result.put("code", "400");
result.put("msg", "用户名或密码错误");
}else{
if(password.equals(user.getPassword())){
jedis = jedisAgent.getResource();
String token = UUID.randomUUID().toString();
jedis.set("REDIS_USER_SESSION_KEY:"+token, Json.toJson(user));
jedis.expire("REDIS_USER_SESSION_KEY:"+token, 1800);
result.put("code", "200");
result.put("msg", "返回用户信息成功");
result.put("token", token);
System.out.println("REDIS_USER_SESSION_KEY:"+token);
}else{
result.put("code", "400");
result.put("msg", "用户名或密码错误");
}
}
}
finally {
Streams.safeClose(jedis);
}
return result;
}
模仿session的东西,因为想测试多台tomcat做集群