注册时缓存cookie、redis操作

String authId = “”;
//判断是否已生成 cookie唯一标示
authId = CookieUtils.getCookieValue(request, gcxId);
//如果没有 生成 并存入cookie
if("".equals(authId) || authId==null){
authId = UUIDUtils.createUuid();
CookieUtils.setCookie(request, response, gcxId, authId);

	}
	//保存用户信息至redis 半小时
	//TODO
	String userJSON =	JSONObject.toJSONString(user,SerializerFeature.WriteMapNullValue);
	stringRedisTemplate.delete("user:"+authId);
	valueOps.set("user:"+authId, userJSON, 60*60*20, TimeUnit.SECONDS);

猜你喜欢

转载自blog.csdn.net/qq_28710139/article/details/84998319