mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 04:39:00 +08:00
feat(cache): 在RedisUtils中增加increment方法并优化验证码缓存服务
- 新增RedisUtils.increment方法用于原子递增操作 - 重构CaptchaCacheServiceProvider使用RedisUtils替代直接stringRedisTemplate调用 - 统一Redis缓存操作工具类方法调用方式
This commit is contained in:
1 parent
bf1e58fb71
commit
00efa97eef
2 files changed
+15
-1
No files matched your search
+1
-1
@@ -40,7 +40,7 @@ public class CaptchaCacheServiceProvider implements CaptchaCacheService {
|
||||
|
||||
@Override
|
||||
public Long increment(String key, long val) {
|
||||
return stringRedisTemplate.opsForValue().increment(key, val);
|
||||
return RedisUtils.increment(key, val);
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+14
@@ -270,6 +270,20 @@ public class RedisUtils {
|
||||
return (T) redisTemplate.execute(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递增操作
|
||||
*
|
||||
* @param key 键
|
||||
* @param val 增加的值
|
||||
* @return 递增后的值
|
||||
*/
|
||||
public Long increment(String key, long val) {
|
||||
RedisTemplate<String, Object> redisTemplate = SpringContextHolder.getBean(RedisTemplate.class);
|
||||
return Optional.ofNullable(redisTemplate)
|
||||
.map(template -> template.opsForValue().increment(key, val))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
// ================================Map=================================
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user