Skip to content

Commit

Permalink
fix: 修复参数缓存未及时过期的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Feb 20, 2024
1 parent 6be1b6c commit 976e9c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@

package top.charles7c.continew.admin.system.model.req;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;

import lombok.Data;

import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;

/**
* 参数重置信息
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package top.charles7c.continew.admin.system.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.alicp.jetcache.anno.CacheInvalidate;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import top.charles7c.continew.admin.common.constant.CacheConstants;
Expand All @@ -28,6 +27,8 @@
import top.charles7c.continew.admin.system.model.req.OptionResetValueReq;
import top.charles7c.continew.admin.system.model.resp.OptionResp;
import top.charles7c.continew.admin.system.service.OptionService;
import top.charles7c.continew.starter.cache.redisson.util.RedisUtils;
import top.charles7c.continew.starter.core.constant.StringConstants;
import top.charles7c.continew.starter.data.mybatis.plus.query.QueryWrapperHelper;

import java.util.List;
Expand All @@ -51,12 +52,13 @@ public List<OptionResp> list(OptionQuery query) {

@Override
public void update(List<OptionReq> req) {
RedisUtils.deleteByPattern(CacheConstants.OPTION_KEY_PREFIX + StringConstants.ASTERISK);
baseMapper.updateBatchById(BeanUtil.copyToList(req, OptionDO.class));
}

@Override
@CacheInvalidate(key = "#req.code", name = CacheConstants.OPTION_KEY_PREFIX, multi = true)
public void resetValue(OptionResetValueReq req) {
RedisUtils.deleteByPattern(CacheConstants.OPTION_KEY_PREFIX + StringConstants.ASTERISK);
baseMapper.lambdaUpdate().set(OptionDO::getValue, null).in(OptionDO::getCode, req.getCode()).update();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public R<List<LabelValueResp<Serializable>>> listDict(@PathVariable String code)
@SaIgnore
@Operation(summary = "查询参数", description = "查询参数")
@GetMapping("/option")
@Cached(name = CacheConstants.OPTION_KEY_PREFIX)
@Cached(key = "#query.code", name = CacheConstants.OPTION_KEY_PREFIX)
public R<List<LabelValueResp<String>>> listOption(@Validated OptionQuery query) {
return R.ok(optionService.list(query)
.stream()
Expand Down

0 comments on commit 976e9c4

Please sign in to comment.