| | |
| | | package com.ruoyi.web.controller.monitor; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.oss.constant.OssConstant; |
| | | import com.ruoyi.system.domain.SysCache; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.redisson.spring.data.connection.RedissonConnectionFactory; |
| | |
| | | CACHES.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码")); |
| | | CACHES.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交")); |
| | | CACHES.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理")); |
| | | CACHES.add(new SysCache(OssConstant.SYS_OSS_KEY, "OSS配置")); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("monitor:cache:list") |
| | | @GetMapping("/getKeys/{cacheName}") |
| | | public R<Collection<String>> getCacheKeys(@PathVariable String cacheName) { |
| | | Iterable<String> iterable = RedisUtils.getClient().getKeys().getKeysByPattern(cacheName + "*"); |
| | | Collection<String> cacheKyes = CollUtil.toCollection(iterable); |
| | | Collection<String> cacheKyes = RedisUtils.keys(cacheName + "*"); |
| | | return R.ok(cacheKyes); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("monitor:cache:list") |
| | | @DeleteMapping("/clearCacheName/{cacheName}") |
| | | public R<Void> clearCacheName(@PathVariable String cacheName) { |
| | | RedisUtils.getClient().getKeys().deleteByPattern(cacheName + "*"); |
| | | RedisUtils.deleteKeys(cacheName + "*"); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | @SaCheckPermission("monitor:cache:list") |
| | | @DeleteMapping("/clearCacheAll") |
| | | public R<Void> clearCacheAll() { |
| | | RedisUtils.getClient().getKeys().deleteByPattern("*"); |
| | | RedisUtils.deleteKeys("*"); |
| | | return R.ok(); |
| | | } |
| | | |