|
@@ -24,93 +24,6 @@ public class RedisUtil {
|
|
@Resource
|
|
@Resource
|
|
RedisTemplate<String, Object> redisTemplate;
|
|
RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
|
-// /**
|
|
|
|
-// * 获取机构信息
|
|
|
|
-// *
|
|
|
|
-// * @param orgId
|
|
|
|
-// * @return
|
|
|
|
-// */
|
|
|
|
-// public Object getOrg(Long orgId) {
|
|
|
|
-// return redisTemplate.opsForValue().get(SystemConstant.ORG + orgId);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * 设置机构信息
|
|
|
|
-// *
|
|
|
|
-// * @param orgId
|
|
|
|
-// * @param o
|
|
|
|
-// */
|
|
|
|
-// public void setOrg(Long orgId, Object o) {
|
|
|
|
-// redisTemplate.opsForValue().set(SystemConstant.ORG + orgId, o, SystemConstant.REDIS_EXPIRE_TIME, TimeUnit.SECONDS);
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// /**
|
|
|
|
-// * 获取机构信息
|
|
|
|
-// *
|
|
|
|
-// * @param orgCode
|
|
|
|
-// * @return
|
|
|
|
-// */
|
|
|
|
-// public Object getOrgCode(String orgCode) {
|
|
|
|
-// return redisTemplate.opsForValue().get(SystemConstant.ORG + orgCode);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * 设置机构信息
|
|
|
|
-// *
|
|
|
|
-// * @param o
|
|
|
|
-// */
|
|
|
|
-// public void setRole(Object o) {
|
|
|
|
-// redisTemplate.opsForList().leftPushAll(SystemConstant.ROLE, o);
|
|
|
|
-// redisTemplate.expire(SystemConstant.ROLE, SystemConstant.REDIS_EXPIRE_TIME, TimeUnit.SECONDS);
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// /**
|
|
|
|
-// * 获取机构信息
|
|
|
|
-// *
|
|
|
|
-// * @return
|
|
|
|
-// */
|
|
|
|
-// public Object getRole() {
|
|
|
|
-// return redisTemplate.opsForList().range(SystemConstant.ROLE, 0, -1);
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// /**
|
|
|
|
-// * 设置机构信息
|
|
|
|
-// *
|
|
|
|
-// * @param orgCode
|
|
|
|
-// * @param o
|
|
|
|
-// */
|
|
|
|
-// public void setOrgCode(String orgCode, Object o) {
|
|
|
|
-// redisTemplate.opsForValue().set(SystemConstant.ORG + orgCode, o, SystemConstant.REDIS_EXPIRE_TIME, TimeUnit.SECONDS);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * 删除机构缓存
|
|
|
|
-// *
|
|
|
|
-// * @param orgId
|
|
|
|
-// */
|
|
|
|
-// public void deleteOrg(Long orgId) {
|
|
|
|
-// redisTemplate.delete(SystemConstant.ORG + orgId);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * 删除机构缓存
|
|
|
|
-// *
|
|
|
|
-// * @param orgCode
|
|
|
|
-// */
|
|
|
|
-// public void deleteOrgCode(String orgCode) {
|
|
|
|
-// redisTemplate.delete(SystemConstant.ORG + orgCode);
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// /**
|
|
|
|
-// * 获取用户信息
|
|
|
|
-// *
|
|
|
|
-// * @param userId
|
|
|
|
-// * @return
|
|
|
|
-// */
|
|
|
|
-// public Object getUser(Long userId) {
|
|
|
|
-// return redisTemplate.opsForValue().get(SystemConstant.USER + userId);
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 获取用户会话信息
|
|
* 获取用户会话信息
|
|
*
|
|
*
|
|
@@ -121,15 +34,6 @@ public class RedisUtil {
|
|
return redisTemplate.opsForValue().get(SystemConstant.SESSION + sessionId);
|
|
return redisTemplate.opsForValue().get(SystemConstant.SESSION + sessionId);
|
|
}
|
|
}
|
|
|
|
|
|
-// /**
|
|
|
|
-// * 删除用户缓存
|
|
|
|
-// *
|
|
|
|
-// * @param userId
|
|
|
|
-// */
|
|
|
|
-// public void deleteUser(Long userId) {
|
|
|
|
-// redisTemplate.delete(SystemConstant.USER + userId);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
/**
|
|
/**
|
|
* 删除用户会话缓存
|
|
* 删除用户会话缓存
|
|
*
|
|
*
|
|
@@ -138,57 +42,6 @@ public class RedisUtil {
|
|
public void deleteUserSession(String sessionId) {
|
|
public void deleteUserSession(String sessionId) {
|
|
redisTemplate.delete(SystemConstant.SESSION + sessionId);
|
|
redisTemplate.delete(SystemConstant.SESSION + sessionId);
|
|
}
|
|
}
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * 设置用户信息
|
|
|
|
-// *
|
|
|
|
-// * @param userId
|
|
|
|
-// * @param o
|
|
|
|
-// */
|
|
|
|
-// public void setUser(Long userId, Object o) {
|
|
|
|
-// redisTemplate.opsForValue().set(SystemConstant.USER + userId, o, SystemConstant.REDIS_EXPIRE_TIME, TimeUnit.SECONDS);
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// /**
|
|
|
|
-// * 设置学生信息
|
|
|
|
-// *
|
|
|
|
-// * @param studentId
|
|
|
|
-// * @param o
|
|
|
|
-// * @param time
|
|
|
|
-// * @param timeUnit
|
|
|
|
-// */
|
|
|
|
-// public void setStudent(Long studentId, Object o, Long time, TimeUnit timeUnit) {
|
|
|
|
-// redisTemplate.opsForValue().set(SystemConstant.STUDENT + studentId, o, time, timeUnit);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * 设置学生信息
|
|
|
|
-// *
|
|
|
|
-// * @param studentId
|
|
|
|
-// * @param o
|
|
|
|
-// */
|
|
|
|
-// public void setStudent(Long studentId, Object o) {
|
|
|
|
-// redisTemplate.opsForValue().set(SystemConstant.STUDENT + studentId, o);
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// /**
|
|
|
|
-// * 删除学生缓存
|
|
|
|
-// *
|
|
|
|
-// * @param studentId
|
|
|
|
-// */
|
|
|
|
-// public void deleteStudent(Long studentId) {
|
|
|
|
-// redisTemplate.delete(SystemConstant.STUDENT + studentId);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * 获取学生信息
|
|
|
|
-// *
|
|
|
|
-// * @param studentId
|
|
|
|
-// * @return
|
|
|
|
-// */
|
|
|
|
-// public Object getStudent(Long studentId) {
|
|
|
|
-// return redisTemplate.opsForValue().get(SystemConstant.STUDENT + studentId);
|
|
|
|
-// }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 设置用户session信息
|
|
* 设置用户session信息
|
|
@@ -225,7 +78,6 @@ public class RedisUtil {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 设置hash
|
|
* 设置hash
|
|
*
|
|
*
|
|
@@ -372,12 +224,14 @@ public class RedisUtil {
|
|
public void expire(String key, int timeOutSecond) {
|
|
public void expire(String key, int timeOutSecond) {
|
|
redisTemplate.expire(key, timeOutSecond, TimeUnit.SECONDS);
|
|
redisTemplate.expire(key, timeOutSecond, TimeUnit.SECONDS);
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**设置过期时间
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 设置过期时间
|
|
|
|
+ *
|
|
* @param key
|
|
* @param key
|
|
* @param timeOut
|
|
* @param timeOut
|
|
*/
|
|
*/
|
|
- public void expire(String key, long timeOut,TimeUnit timeUnit) {
|
|
|
|
|
|
+ public void expire(String key, long timeOut, TimeUnit timeUnit) {
|
|
redisTemplate.expire(key, timeOut, timeUnit);
|
|
redisTemplate.expire(key, timeOut, timeUnit);
|
|
}
|
|
}
|
|
|
|
|