正确的删除姿势
This commit is contained in:
parent
fe4edbd686
commit
639bc37804
@ -105,11 +105,11 @@ public class RedisService
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单个key下的某个值
|
||||
* 删除单个key下的值
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
public void deleteSetVal(final String key, final Object val) {
|
||||
public void deleteSetVal(final String key, final Object... val) {
|
||||
|
||||
redisTemplate.opsForSet().remove(key, val);
|
||||
}
|
||||
|
||||
@ -50,9 +50,7 @@ public class PileController {
|
||||
@PostMapping("pile/whitelist/delete/{stationId}")
|
||||
public Object deleteWhitelist(@PathVariable("stationId") Long stationId, @RequestBody Set<String> pileNoSet) {
|
||||
|
||||
Set<String> cacheWhitelist = REDIS.getCacheSet("PILE_WHITELIST");
|
||||
cacheWhitelist.removeAll(pileNoSet);
|
||||
REDIS.setCacheSet("PILE_WHITELIST", cacheWhitelist);
|
||||
REDIS.deleteSetVal("PILE_WHITELIST", pileNoSet.toArray());
|
||||
String stationKey = "station:".concat(stationId.toString());
|
||||
ChargingStationDto cacheStation = REDIS.getCacheObject(stationKey);
|
||||
cacheStation.getPiles().removeAll(pileNoSet);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user