publish 2.0.0.rc15
This commit is contained in:
@@ -109,7 +109,7 @@ public class EncryptConfig {
|
||||
if (num > 5) {
|
||||
throw new ApiException("登录失败已达6次,请10分钟后再试");
|
||||
}
|
||||
TsCacheService.of().put(clientIp, String.valueOf(num + 1), 10 * 60 * 1000);
|
||||
TsCacheService.of().put(clientIp, String.valueOf(num + 1), 10 * 60);
|
||||
throw new ApiException("账号或密码错误");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,24 +29,24 @@ public class TsCacheService {
|
||||
tsCacheHandler.put(key, value);
|
||||
}
|
||||
|
||||
public void put(String key, String value, long timeout) {
|
||||
tsCacheHandler.put(key, value, timeout);
|
||||
public void put(String key, String value, long seconds) {
|
||||
tsCacheHandler.put(key, value, seconds);
|
||||
}
|
||||
|
||||
public void putObj(String key, Object value, long timeout) {
|
||||
tsCacheHandler.put(key, JSONUtil.toJsonStr(value), timeout);
|
||||
public void putObj(String key, Object value, long seconds) {
|
||||
tsCacheHandler.put(key, JSONUtil.toJsonStr(value), seconds);
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
return tsCacheHandler.get(key);
|
||||
}
|
||||
|
||||
public String get(String key, long timeout) {
|
||||
return tsCacheHandler.get(key, timeout);
|
||||
public String get(String key, long seconds) {
|
||||
return tsCacheHandler.get(key, seconds);
|
||||
}
|
||||
|
||||
public <T> T getObj(String key, Class<T> tClass, long timeout) {
|
||||
return JSONUtil.toBean(get(key, timeout), tClass, true);
|
||||
public <T> T getObj(String key, Class<T> tClass, long seconds) {
|
||||
return JSONUtil.toBean(get(key, seconds), tClass, true);
|
||||
}
|
||||
|
||||
public void remove(String key) {
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.tiesheng.util.service.cache;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -23,12 +22,12 @@ public class TsCacheRedisHandler implements TsCacheHandler {
|
||||
|
||||
@Override
|
||||
public void put(String key, String value) {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
redisTemplate.opsForValue().set(key, value, 2 * 60, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(String key, String value, long timeout) {
|
||||
redisTemplate.opsForValue().set(key, value, timeout, TimeUnit.MICROSECONDS);
|
||||
public void put(String key, String value, long seconds) {
|
||||
redisTemplate.opsForValue().set(key, value, seconds, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,10 +37,10 @@ public class TsCacheRedisHandler implements TsCacheHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(String key, long timeout) {
|
||||
if (timeout > 0) {
|
||||
return redisTemplate.opsForValue().getAndExpire(key, timeout, TimeUnit.MICROSECONDS);
|
||||
} else if (timeout == 0) {
|
||||
public String get(String key, long seconds) {
|
||||
if (seconds > 0) {
|
||||
return redisTemplate.opsForValue().getAndExpire(key, seconds, TimeUnit.SECONDS);
|
||||
} else if (seconds == 0) {
|
||||
return redisTemplate.opsForValue().getAndDelete(key);
|
||||
}
|
||||
return redisTemplate.opsForValue().get(key);
|
||||
|
||||
@@ -37,8 +37,8 @@ public class TsCacheTimedHandler implements TsCacheHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(String key, String value, long timeout) {
|
||||
getTimedCache().put(key, value, timeout);
|
||||
public void put(String key, String value, long seconds) {
|
||||
getTimedCache().put(key, value, seconds * 1000);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,11 +48,11 @@ public class TsCacheTimedHandler implements TsCacheHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(String key, long timeout) {
|
||||
public String get(String key, long seconds) {
|
||||
String value = getTimedCache().get(key, false);
|
||||
if (timeout > 0) {
|
||||
getTimedCache().put(key, value, timeout);
|
||||
} else if (timeout == 0) {
|
||||
if (seconds > 0) {
|
||||
getTimedCache().put(key, value, seconds * 1000);
|
||||
} else if (seconds == 0) {
|
||||
getTimedCache().remove(key);
|
||||
}
|
||||
return value;
|
||||
|
||||
Reference in New Issue
Block a user