我正在我的項目中實現一個 redis-shiro 會話管理功能,目前我對 Shiro 和 Redis 的信息很少。我想知道調用以下內容是否會每次都命中 redis 數據庫,以檢查 redis 數據庫中是否存在任何會話 Id。服務中的代碼Subject currentUser = SecurityUtils.getSubject(); Session session = currentUser.getSession();控制器中的代碼: public String getSomrthing(@CookieValue("JSESSIONID") String fooCookie){ callingSomeServiceMethod(fooCookie); return "It does not matter"; }我們是否必須像我們的服務中那樣手動匹配sentialId,或者Shiro會自動匹配它,因為我的應用程序將在多實例環境中運行。Subject currentUser = SecurityUtils.getSubject(); if(currentUser.getId.equals(fooCookie)){ //.....Some Code //.....Some Code }
1 回答

慕碼人2483693
TA貢獻1860條經驗 獲得超9個贊
會話將為每個請求最多查找一次,具體取決于您配置的任何其他緩存。
但是,您不會直接從控制器管理/查找會話Id。所有這些邏輯都是透明的,并由 Shiro 和/或您的 servlet 容器的會話管理處理。
添加回答
舉報
0/150
提交
取消