mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-28 23:26:00 +00:00
redis key load optimalization
This commit is contained in:
@@ -5,8 +5,7 @@
|
|||||||
import LoadingInfo from '../elements/LoadingInfo.svelte';
|
import LoadingInfo from '../elements/LoadingInfo.svelte';
|
||||||
import { apiCall } from '../utility/api';
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
// const SHOW_INCREMENT = 500;
|
const SHOW_INCREMENT = 100;
|
||||||
const SHOW_INCREMENT = 10;
|
|
||||||
|
|
||||||
import DbKeysTreeNode from './DbKeysTreeNode.svelte';
|
import DbKeysTreeNode from './DbKeysTreeNode.svelte';
|
||||||
|
|
||||||
@@ -33,8 +32,6 @@
|
|||||||
database,
|
database,
|
||||||
root,
|
root,
|
||||||
filter,
|
filter,
|
||||||
reloadToken,
|
|
||||||
reloadToken2,
|
|
||||||
limit: maxShowCount + 1,
|
limit: maxShowCount + 1,
|
||||||
});
|
});
|
||||||
items = result;
|
items = result;
|
||||||
@@ -54,11 +51,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
|
reloadToken;
|
||||||
loadingWhole = true;
|
loadingWhole = true;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if loading && items.length == 0}
|
{#if loadingWhole}
|
||||||
<LoadingInfo message="Loading key list" wrapper />
|
<LoadingInfo message="Loading key list" wrapper />
|
||||||
{:else}
|
{:else}
|
||||||
{#each items.slice(0, maxShowCount) as item}
|
{#each items.slice(0, maxShowCount) as item}
|
||||||
|
|||||||
@@ -194,14 +194,36 @@ const driver = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getKeys(dbhan, keyQuery = '*') {
|
async getKeys(dbhan, keyQuery = '*') {
|
||||||
const res = [];
|
const stream = dbhan.client.scanStream({
|
||||||
let cursor = 0;
|
match: keyQuery,
|
||||||
do {
|
count: 1000,
|
||||||
const [strCursor, keys] = await dbhan.client.scan(cursor, 'MATCH', keyQuery, 'COUNT', 100);
|
});
|
||||||
res.push(...keys);
|
|
||||||
cursor = parseInt(strCursor);
|
const keys = [];
|
||||||
} while (cursor > 0);
|
|
||||||
return res;
|
stream.on('data', (resultKeys) => {
|
||||||
|
for (const key of resultKeys) {
|
||||||
|
keys.push(key);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
stream.on('end', () => {
|
||||||
|
resolve(keys);
|
||||||
|
});
|
||||||
|
stream.on('error', (err) => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// const res = [];
|
||||||
|
// let cursor = 0;
|
||||||
|
// do {
|
||||||
|
// const [strCursor, keys] = await dbhan.client.scan(cursor, 'MATCH', keyQuery, 'COUNT', 100);
|
||||||
|
// res.push(...keys);
|
||||||
|
// cursor = parseInt(strCursor);
|
||||||
|
// } while (cursor > 0);
|
||||||
|
// return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
extractKeysFromLevel(dbhan, root, keys) {
|
extractKeysFromLevel(dbhan, root, keys) {
|
||||||
|
|||||||
Reference in New Issue
Block a user