Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions redis-template-tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.netease.lowcode</groupId>
<artifactId>redis-template-tool</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
Expand Down Expand Up @@ -40,7 +40,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<!-- 强制指定新版Commons Pool2 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.*;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.util.*;
import java.util.concurrent.TimeUnit;
Expand All @@ -15,6 +17,34 @@ public class RedisTool {
@Autowired
public RedisTemplate<String, String> redisTemplate;

/**
* 是否存在key,返回true/false
*
* @param key
* @return
*/
@NaslLogic
public Boolean hasKey(String key) {
if (StringUtils.isEmpty(key)) {
return false;
}
return redisTemplate.hasKey(key);
}

/**
* 批量删除key
*
* @param keys
* @return
*/
@NaslLogic
public Long deleteKeys(List<String> keys) {
if (CollectionUtils.isEmpty(keys)) {
return 0L;
}
return redisTemplate.delete(keys);
}

/**
* 设置 Redis 中指定 key 的过期时间
*
Expand Down
Loading