1. 程式人生 > >註冊時快取cookie、redis操作

註冊時快取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);