mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-04 00:10:25 +08:00
feat: redis scan优化
This commit is contained in:
@@ -9,11 +9,11 @@
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.0.10",
|
||||
"asciinema-player": "^3.0.1",
|
||||
"axios": "^1.1.2",
|
||||
"axios": "^1.2.0",
|
||||
"countup.js": "^2.0.7",
|
||||
"cropperjs": "^1.5.11",
|
||||
"echarts": "^5.3.3",
|
||||
"element-plus": "^2.2.23",
|
||||
"echarts": "^5.4.0",
|
||||
"element-plus": "^2.2.26",
|
||||
"jsencrypt": "^3.2.1",
|
||||
"lodash": "^4.17.21",
|
||||
"mitt": "^3.0.0",
|
||||
|
||||
@@ -3,7 +3,7 @@ const config = {
|
||||
baseWsUrl: `${(window as any).globalConfig.BaseWsUrl || `${location.protocol == 'https:' ? 'wss:' : 'ws:'}//${location.host}`}/api`,
|
||||
|
||||
// 系统版本
|
||||
version: 'v1.3.0'
|
||||
version: 'v1.3.1'
|
||||
}
|
||||
|
||||
export default config
|
||||
@@ -129,6 +129,7 @@ const state = reactive({
|
||||
},
|
||||
scanParam: {
|
||||
id: null as any,
|
||||
mode: '',
|
||||
db: '',
|
||||
match: null,
|
||||
count: 10,
|
||||
@@ -194,8 +195,15 @@ const getTags = async () => {
|
||||
};
|
||||
|
||||
const changeRedis = (id: number) => {
|
||||
resetScanParam(id);
|
||||
state.dbList = (state.redisList.find((x: any) => x.id == id) as any).db.split(',');
|
||||
resetScanParam();
|
||||
if (id != 0) {
|
||||
const redis: any = state.redisList.find((x: any) => x.id == id);
|
||||
if (redis) {
|
||||
state.dbList = (state.redisList.find((x: any) => x.id == id) as any).db.split(',');
|
||||
state.scanParam.mode = redis.mode;
|
||||
}
|
||||
}
|
||||
|
||||
// 默认选中配置的第一个库
|
||||
state.scanParam.db = state.dbList[0];
|
||||
state.keys = [];
|
||||
@@ -203,7 +211,7 @@ const changeRedis = (id: number) => {
|
||||
};
|
||||
|
||||
const changeDb = () => {
|
||||
resetScanParam(state.scanParam.id as any);
|
||||
resetScanParam();
|
||||
state.keys = [];
|
||||
state.dbsize = 0;
|
||||
searchKey();
|
||||
@@ -213,16 +221,28 @@ const scan = async () => {
|
||||
isTrue(state.scanParam.id != null, '请先选择redis');
|
||||
notBlank(state.scanParam.count, 'count不能为空');
|
||||
|
||||
const match = state.scanParam.match;
|
||||
if (!match || (match as string).length < 4) {
|
||||
isTrue(state.scanParam.count <= 200, 'key为空或小于4字符时, count不能超过200');
|
||||
} else {
|
||||
isTrue(state.scanParam.count <= 20000, 'count不能超过20000');
|
||||
const match: string = state.scanParam.match || '';
|
||||
if (!match) {
|
||||
isTrue(state.scanParam.count <= 100, "key搜索条件为空时, count不能大于100")
|
||||
} else if (match.indexOf('*') != -1) {
|
||||
const dbsize = state.dbsize;
|
||||
// 如果为模糊搜索,并且搜索的key模式大于指定字符数,则将count设大点scan
|
||||
if (match.length > 10) {
|
||||
state.scanParam.count = dbsize > 100000 ? Math.floor(dbsize / 10) : 1000;
|
||||
} else {
|
||||
state.scanParam.count = 100;
|
||||
}
|
||||
}
|
||||
|
||||
const scanParam = { ...state.scanParam }
|
||||
// 集群模式count设小点,因为后端会从所有master节点scan一遍然后合并结果,默认假设redis集群有3个master
|
||||
if (scanParam.mode == 'cluster') {
|
||||
scanParam.count = Math.floor(state.scanParam.count / 3)
|
||||
}
|
||||
|
||||
state.loading = true;
|
||||
try {
|
||||
const res = await redisApi.scan.request(state.scanParam);
|
||||
const res = await redisApi.scan.request(scanParam);
|
||||
state.keys = res.keys;
|
||||
state.dbsize = res.dbSize;
|
||||
state.scanParam.cursor = res.cursor;
|
||||
@@ -252,15 +272,8 @@ const clear = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const resetScanParam = (id: number = 0) => {
|
||||
const resetScanParam = () => {
|
||||
state.scanParam.count = 10;
|
||||
if (id != 0) {
|
||||
const redis: any = state.redisList.find((x: any) => x.id == id);
|
||||
// 集群模式count设小点,因为后端会从所有master节点scan一遍然后合并结果
|
||||
if (redis && redis.mode == 'cluster') {
|
||||
state.scanParam.count = 4;
|
||||
}
|
||||
}
|
||||
state.scanParam.match = null;
|
||||
state.scanParam.cursor = {};
|
||||
};
|
||||
|
||||
@@ -476,10 +476,10 @@ asynckit@^0.4.0:
|
||||
resolved "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz"
|
||||
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==
|
||||
|
||||
axios@^1.1.2:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.npmmirror.com/axios/-/axios-1.1.2.tgz"
|
||||
integrity sha512-bznQyETwElsXl2RK7HLLwb5GPpOLlycxHCtrpDR/4RqqBzjARaOTo3jz4IgtntWUYee7Ne4S8UHd92VCuzPaWA==
|
||||
axios@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.npmmirror.com/axios/-/axios-1.2.0.tgz#1cb65bd75162c70e9f8d118a905126c4a201d383"
|
||||
integrity sha512-zT7wZyNYu3N5Bu0wuZ6QccIf93Qk1eV8LOewxgjOZFd2DenOs98cJ7+Y6703d0wkaXGY6/nZd4EweJaHz9uzQw==
|
||||
dependencies:
|
||||
follow-redirects "^1.15.0"
|
||||
form-data "^4.0.0"
|
||||
@@ -654,18 +654,18 @@ dt-sql-parser@^4.0.0-beta.2.2:
|
||||
"@types/antlr4" "4.7.0"
|
||||
antlr4 "4.7.2"
|
||||
|
||||
echarts@^5.3.3:
|
||||
version "5.3.3"
|
||||
resolved "https://registry.npmmirror.com/echarts/-/echarts-5.3.3.tgz"
|
||||
integrity sha512-BRw2serInRwO5SIwRviZ6Xgm5Lb7irgz+sLiFMmy/HOaf4SQ+7oYqxKzRHAKp4xHQ05AuHw1xvoQWJjDQq/FGw==
|
||||
echarts@^5.4.0:
|
||||
version "5.4.0"
|
||||
resolved "https://registry.npmmirror.com/echarts/-/echarts-5.4.0.tgz#a9a8e5367293a397408d3bf3e2638b869249ce04"
|
||||
integrity sha512-uPsO9VRUIKAdFOoH3B0aNg7NRVdN7aM39/OjovjO9MwmWsAkfGyeXJhK+dbRi51iDrQWliXV60/XwLA7kg3z0w==
|
||||
dependencies:
|
||||
tslib "2.3.0"
|
||||
zrender "5.3.2"
|
||||
zrender "5.4.0"
|
||||
|
||||
element-plus@^2.2.23:
|
||||
version "2.2.23"
|
||||
resolved "https://registry.npmmirror.com/element-plus/-/element-plus-2.2.23.tgz#63f512bcf74e46d6bec6d8882d9dab40c1fbebcb"
|
||||
integrity sha512-/7BtebETiknsW2TpSwt5RIpXxFQ1sbYoRelJqeiB1K9LcL0MwyQJ1rZSuWHBCHduMvfpogNZ66dwp2Giv9lYbg==
|
||||
element-plus@^2.2.26:
|
||||
version "2.2.26"
|
||||
resolved "https://registry.npmmirror.com/element-plus/-/element-plus-2.2.26.tgz#5e46aa5d8127786bb158713957f8a253b35bf019"
|
||||
integrity sha512-O/rdY5m9DkclpVg8r3GynyqCunm7MxSR142xSsjrZA77bi7bcwA3SIy6SPEDqHi5R4KqgkGYgKSp4Q4e3irbYg==
|
||||
dependencies:
|
||||
"@ctrl/tinycolor" "^3.4.1"
|
||||
"@element-plus/icons-vue" "^2.0.6"
|
||||
@@ -1806,9 +1806,9 @@ yallist@^4.0.0:
|
||||
resolved "https://registry.nlark.com/yallist/download/yallist-4.0.0.tgz"
|
||||
integrity sha1-m7knkNnA7/7GO+c1GeEaNQGaOnI=
|
||||
|
||||
zrender@5.3.2:
|
||||
version "5.3.2"
|
||||
resolved "https://registry.npmmirror.com/zrender/-/zrender-5.3.2.tgz"
|
||||
integrity sha512-8IiYdfwHj2rx0UeIGZGGU4WEVSDEdeVCaIg/fomejg1Xu6OifAL1GVzIPHg2D+MyUkbNgPWji90t0a8IDk+39w==
|
||||
zrender@5.4.0:
|
||||
version "5.4.0"
|
||||
resolved "https://registry.npmmirror.com/zrender/-/zrender-5.4.0.tgz#d4f76e527b2e3bbd7add2bdaf27a16af85785576"
|
||||
integrity sha512-rOS09Z2HSVGFs2dn/TuYk5BlCaZcVe8UDLLjj1ySYF828LATKKdxuakSZMvrDz54yiKPDYVfjdKqcX8Jky3BIA==
|
||||
dependencies:
|
||||
tslib "2.3.0"
|
||||
|
||||
Reference in New Issue
Block a user