Browse Source

redis pipelined批量取值加上解析器

dev_shibei_match
wangchao 5 years ago
parent
commit
82cf902db8
  1. 14
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java
  2. 17
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java

14
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java

@ -152,18 +152,4 @@ public class BadgeController {
badgeService.audit(tokenDto, formDTO);
return new Result();
}
@Autowired
private UserBadgeRedis redis;
@PostMapping("compensation-mechanism")
public Result compensationMechanism(@RequestParam("userId")String userId,@RequestParam("customerId")String customerId,@RequestParam("b1")String b1,
@RequestParam("b2")String b2){
redis.pushOrRemoveUserBadge4List(userId,b1,customerId);
redis.pushOrRemoveUserBadge4List(userId,b1,customerId);
redis.pushOrRemoveUserBadge4List(userId,b1,customerId);
redis.pushOrRemoveUserBadge4List(userId,b2,customerId);
redis.batchClearUserBadgeCache(customerId);
redis.obtainUserBadge2List(userId,customerId);
return new Result();
}
}

17
epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java

@ -18,12 +18,11 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.StringRedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Set;
@ -189,5 +188,19 @@ public class UserBadgeRedis {
}
public List<String> pipelinedReturnKeys(String customerId){
List<String> list = redisTemplate.executePipelined(new RedisCallback<List<String>>() {
@Nullable
@Override
public List<String> doInRedis(RedisConnection connection) throws DataAccessException {
connection.openPipeline();
Set<byte[]> keys = connection.keys(redisTemplate.getKeySerializer().serialize(UserRedisKeys.getResiUserBadgeKey(customerId, null)));
return null;
}
},redisTemplate.getKeySerializer());
return list;
}
}

Loading…
Cancel
Save