feat: 为前端增加缓存接口
This commit is contained in:
parent
b47e001237
commit
142b11837f
|
|
@ -0,0 +1,47 @@
|
|||
package com.nflg.product.bomnew.api.user;
|
||||
|
||||
import com.nflg.product.base.core.api.BaseApi;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import nflg.product.common.vo.ResultVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* @author 曹鹏飞
|
||||
* @date 2024/4/9 09:22:09
|
||||
*/
|
||||
@Api(tags = "缓存接口")
|
||||
@RestController
|
||||
@RequestMapping("bom/new/cache")
|
||||
public class CacheApi extends BaseApi {
|
||||
|
||||
private static final String PREFIX = "frontend:";
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
@PostMapping("set")
|
||||
@ApiOperation("设置缓存")
|
||||
public ResultVO setCache(@Valid @RequestParam @NonNull String key, @Valid @RequestParam @NonNull String content) {
|
||||
redisTemplate.boundValueOps(PREFIX + key).set(content);
|
||||
return ResultVO.success();
|
||||
}
|
||||
|
||||
@GetMapping("get")
|
||||
@ApiOperation("获取缓存")
|
||||
public ResultVO getCache(@Valid @RequestParam @NonNull String key) {
|
||||
return ResultVO.success(redisTemplate.boundValueOps(PREFIX + key).get());
|
||||
}
|
||||
|
||||
@PostMapping("del")
|
||||
@ApiOperation("删除缓存")
|
||||
public ResultVO delCache(@Valid @RequestParam @NonNull String key) {
|
||||
redisTemplate.delete(PREFIX + key);
|
||||
return ResultVO.success();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
nacos.server-addr=192.168.0.191:8848
|
||||
|
||||
spring.cache.type=redis
|
||||
spring.redis.database=0
|
||||
spring.redis.host=192.168.0.191
|
||||
spring.redis.password=
|
||||
spring.redis.port=6379
|
||||
spring.redis.timeout=0
|
||||
spring.redis.ssl=false
|
||||
spring.redis.lettuce.pool.max-wait=1ms
|
||||
spring.redis.lettuce.pool.max-wait=-1ms
|
||||
spring.redis.lettuce.pool.max-active=8
|
||||
spring.redis.lettuce.pool.max-idle=8
|
||||
spring.redis.lettuce.pool.min-idle=0
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
#nacos.server-addr=114.132.64.230:8123
|
||||
nacos.server-addr=192.168.0.194:8848
|
||||
|
||||
|
||||
spring.cache.type=redis
|
||||
spring.redis.database=0
|
||||
spring.redis.host=192.168.0.194
|
||||
spring.redis.password=
|
||||
spring.redis.port=6379
|
||||
spring.redis.timeout=0
|
||||
spring.redis.ssl=false
|
||||
spring.redis.lettuce.pool.max-wait=1ms
|
||||
spring.redis.lettuce.pool.max-wait=-1ms
|
||||
spring.redis.lettuce.pool.max-active=8
|
||||
spring.redis.lettuce.pool.max-idle=8
|
||||
spring.redis.lettuce.pool.min-idle=0
|
||||
|
|
|
|||
Loading…
Reference in New Issue