|
|
@ -16,10 +16,13 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.data.redis.core.RedisCallback; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
import static com.epmet.commons.tools.redis.RedisUtils.MINUTE_THIRTY_EXPIRE; |
|
|
|
|
|
|
@ -37,6 +40,8 @@ public class UserBadgeRedis { |
|
|
|
private BadgeDao badgeDao; |
|
|
|
@Autowired |
|
|
|
private UserBadgeService badgeService; |
|
|
|
@Autowired |
|
|
|
private RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 获取客户徽章信息 |
|
|
@ -146,5 +151,25 @@ public class UserBadgeRedis { |
|
|
|
return NumConstant.ONE; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 批量清除用户徽章信息,用处:在客户取消点亮某个徽章后,批量清除该客户下所有用户的徽章缓存,当需要查取时再次初始化进缓存中 |
|
|
|
* @param customerId |
|
|
|
* @return void |
|
|
|
* @author wangc |
|
|
|
* @date 2020.11.09 10:02 |
|
|
|
*/ |
|
|
|
public void batchClearUserBadgeCache(String customerId){ |
|
|
|
redisTemplate.executePipelined((RedisCallback<String>) connection ->{ |
|
|
|
Set<byte[]> keys = |
|
|
|
connection.keys(redisTemplate.getKeySerializer().serialize(UserRedisKeys.getResiUserBadgeKey(customerId, null))); |
|
|
|
if(!CollectionUtils.isEmpty(keys)){ |
|
|
|
keys.forEach( ser -> {connection.del(ser);}); |
|
|
|
} |
|
|
|
return null; |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|