Authored by Xu

添加剩余时间

... ... @@ -12,6 +12,8 @@ public class MaliciousIpLook {
*/
private String ip;
private Long ttl;
public String getIp() {
return ip;
}
... ... @@ -19,4 +21,12 @@ public class MaliciousIpLook {
public void setIp(String ip) {
this.ip = ip;
}
public Long getTtl() {
return ttl;
}
public void setTtl(Long ttl) {
this.ttl = ttl;
}
}
\ No newline at end of file
... ...
... ... @@ -175,6 +175,7 @@ public class MaliciousIpServiceImpl implements MaliciousIpService {
for (byte[] byt : values) {
String key = new String(byt);
look = new MaliciousIpLook();
look.setTtl(redisReadMalicious.getTtl(key));
look.setIp(key.substring("yh:mip:".length()));
looks.add(look);
}
... ...
... ... @@ -44,6 +44,16 @@ public class RedisReadMaliciousUtil {
return value;
}
public Long getTtl(String key){
Long ttl = null;
try{
ttl = getKeysInRedisTTLApi(aws1Template, key);
}catch(Exception e){
logger.error(" - RedisReadUtil - getIpsBL - error", e);
}
return ttl;
}
/**
* 根据key获取
* @param redisTemplate
... ... @@ -52,4 +62,8 @@ public class RedisReadMaliciousUtil {
private Set<byte[]> getKeysInRedisApi(RedisTemplate<String, String> redisTemplate, String pattern){
return redisTemplate.getConnectionFactory().getConnection().keys(pattern.getBytes());
}
private Long getKeysInRedisTTLApi(RedisTemplate<String, String> redisTemplate, String key){
return redisTemplate.getExpire(key);
}
}
\ No newline at end of file
... ...