本文整理匯總了Java中com.zheng.common.util.RedisUtil.get方法的典型用法代碼示例。如果您正苦於以下問題:Java RedisUtil.get方法的具體用法?Java RedisUtil.get怎麽用?Java RedisUtil.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.zheng.common.util.RedisUtil
的用法示例。
在下文中一共展示了RedisUtil.get方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getActiveSessions
import com.zheng.common.util.RedisUtil; //導入方法依賴的package包/類
/**
* 獲取會話列表
* @param offset
* @param limit
* @return
*/
public Map getActiveSessions(int offset, int limit) {
Map sessions = new HashMap();
Jedis jedis = RedisUtil.getJedis();
// 獲取在線會話總數
long total = jedis.llen(ZHENG_UPMS_SERVER_SESSION_IDS);
// 獲取當前頁會話詳情
List<String> ids = jedis.lrange(ZHENG_UPMS_SERVER_SESSION_IDS, offset, (offset + limit - 1));
List<Session> rows = new ArrayList<>();
for (String id : ids) {
String session = RedisUtil.get(ZHENG_UPMS_SHIRO_SESSION_ID + "_" + id);
// 過濾redis過期session
if (null == session) {
RedisUtil.lrem(ZHENG_UPMS_SERVER_SESSION_IDS, 1, id);
total = total - 1;
continue;
}
rows.add(SerializableUtil.deserialize(session));
}
jedis.close();
sessions.put("total", total);
sessions.put("rows", rows);
return sessions;
}
示例2: login
import com.zheng.common.util.RedisUtil; //導入方法依賴的package包/類
@ApiOperation(value = "登錄")
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login(HttpServletRequest request) {
Subject subject = SecurityUtils.getSubject();
Session session = subject.getSession();
String serverSessionId = session.getId().toString();
// 判斷是否已登錄,如果已登錄,則回跳
String code = RedisUtil.get(ZHENG_UPMS_SERVER_SESSION_ID + "_" + serverSessionId);
// code校驗值
if (StringUtils.isNotBlank(code)) {
// 回跳
String backurl = request.getParameter("backurl");
String username = (String) subject.getPrincipal();
if (StringUtils.isBlank(backurl)) {
backurl = "/";
} else {
if (backurl.contains("?")) {
backurl += "&upms_code=" + code + "&upms_username=" + username;
} else {
backurl += "?upms_code=" + code + "&upms_username=" + username;
}
}
_log.debug("認證中心帳號通過,帶code回跳:{}", backurl);
return "redirect:" + backurl;
}
return "/sso/login.jsp";
}
示例3: forceout
import com.zheng.common.util.RedisUtil; //導入方法依賴的package包/類
/**
* 強製退出
* @param ids
* @return
*/
public int forceout(String ids) {
String[] sessionIds = ids.split(",");
for (String sessionId : sessionIds) {
// 會話增加強製退出屬性標識,當此會話訪問係統時,判斷有該標識,則退出登錄
String session = RedisUtil.get(ZHENG_UPMS_SHIRO_SESSION_ID + "_" + sessionId);
UpmsSession upmsSession = (UpmsSession) SerializableUtil.deserialize(session);
upmsSession.setStatus(UpmsSession.OnlineStatus.force_logout);
upmsSession.setAttribute("FORCE_LOGOUT", "FORCE_LOGOUT");
RedisUtil.set(ZHENG_UPMS_SHIRO_SESSION_ID + "_" + sessionId, SerializableUtil.serialize(upmsSession), (int) upmsSession.getTimeout() / 1000);
}
return sessionIds.length;
}
示例4: login
import com.zheng.common.util.RedisUtil; //導入方法依賴的package包/類
@ApiOperation(value = "登錄")
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login(HttpServletRequest request) {
Subject subject = SecurityUtils.getSubject();
Session session = subject.getSession();
String serverSessionId = session.getId().toString();
// 判斷是否已登錄,如果已登錄,則回跳
String code = RedisUtil.get(ZHENG_UPMS_SERVER_SESSION_ID + "_" + serverSessionId);
// code校驗值
if (StringUtils.isNotBlank(code)) {
// 回跳
String backurl = request.getParameter("backurl");
String username = (String) subject.getPrincipal();
if (StringUtils.isBlank(backurl)) {
backurl = "/";
} else {
if (backurl.contains("?")) {
backurl += "&upms_code=" + code + "&upms_username=" + username;
} else {
backurl += "?upms_code=" + code + "&upms_username=" + username;
}
}
LOGGER.debug("認證中心帳號通過,帶code回跳:{}", backurl);
return "redirect:" + backurl;
}
return "/sso/login.jsp";
}
示例5: doReadSession
import com.zheng.common.util.RedisUtil; //導入方法依賴的package包/類
@Override
protected Session doReadSession(Serializable sessionId) {
String session = RedisUtil.get(ZHENG_UPMS_SHIRO_SESSION_ID + "_" + sessionId);
_log.debug("doReadSession >>>>> sessionId={}", sessionId);
return SerializableUtil.deserialize(session);
}
示例6: doReadSession
import com.zheng.common.util.RedisUtil; //導入方法依賴的package包/類
@Override
protected Session doReadSession(Serializable sessionId) {
String session = RedisUtil.get(ZHENG_UPMS_SHIRO_SESSION_ID + "_" + sessionId);
LOGGER.debug("doReadSession >>>>> sessionId={}", sessionId);
return SerializableUtil.deserialize(session);
}