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