日志切面功能整合
This commit is contained in:
@@ -7,6 +7,9 @@ package com.czg.config;
|
||||
*/
|
||||
public interface RedisCst {
|
||||
String LOGIN_CODE = "login:code:";
|
||||
String SYS_LOG_KEY = "sys:log:";
|
||||
|
||||
|
||||
|
||||
String SMS_CODE = "sms:code:";
|
||||
}
|
||||
|
||||
@@ -17,6 +17,16 @@ import java.util.concurrent.TimeUnit;
|
||||
@Component
|
||||
public class RedisService {
|
||||
|
||||
/**
|
||||
* 默认过期时长为24小时,单位:秒
|
||||
*/
|
||||
public final static long DEFAULT_EXPIRE = 60 * 60 * 24L;
|
||||
|
||||
/**
|
||||
* 不设置过期时长
|
||||
*/
|
||||
public final static long NOT_EXPIRE = -1L;
|
||||
|
||||
@Autowired
|
||||
private final RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@@ -554,4 +564,20 @@ public class RedisService {
|
||||
}
|
||||
}
|
||||
|
||||
public void leftPush(String key, Object value) {
|
||||
leftPush(key, value, DEFAULT_EXPIRE);
|
||||
}
|
||||
|
||||
public void leftPush(String key, Object value, long expire) {
|
||||
redisTemplate.opsForList().leftPush(key, value);
|
||||
|
||||
if (expire != NOT_EXPIRE) {
|
||||
expire(key, expire);
|
||||
}
|
||||
}
|
||||
|
||||
public Object rightPop(String key) {
|
||||
return redisTemplate.opsForList().rightPop(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user