diff --git a/packages/web/src/widgets/DbKeysSubTree.svelte b/packages/web/src/widgets/DbKeysSubTree.svelte index 6501fc1f4..c9f081aad 100644 --- a/packages/web/src/widgets/DbKeysSubTree.svelte +++ b/packages/web/src/widgets/DbKeysSubTree.svelte @@ -1,4 +1,6 @@ diff --git a/plugins/dbgate-plugin-redis/src/backend/driver.js b/plugins/dbgate-plugin-redis/src/backend/driver.js index 47df6bf82..5efd18425 100644 --- a/plugins/dbgate-plugin-redis/src/backend/driver.js +++ b/plugins/dbgate-plugin-redis/src/backend/driver.js @@ -71,17 +71,17 @@ const driver = { }, async loadKeys(pool, root = '') { - const keys = await this.getKeys(pool, root); + const keys = await this.getKeys(pool, root ? `${root}:*` : '*'); const res = this.extractKeysFromLevel(root, keys); await this.enrichKeyInfo(pool, res); return res; }, - async getKeys(pool, root = '') { + async getKeys(pool, keyQuery = '*') { const res = []; let cursor = 0; do { - const [strCursor, keys] = await pool.scan(cursor, 'MATCH', root ? `${root}:*` : '*', 'COUNT', 100); + const [strCursor, keys] = await pool.scan(cursor, 'MATCH', keyQuery, 'COUNT', 100); res.push(...keys); cursor = parseInt(strCursor); } while (cursor > 0); @@ -187,7 +187,17 @@ const driver = { return res; }, + async deleteBranch(pool, keyQuery) { + const keys = await this.getKeys(pool, keyQuery); + const keysChunked = _.chunk(keys, 10); + await async.eachLimit(keysChunked, 10, async (keysChunk) => await pool.del(...keysChunk)); + }, + async callMethod(pool, method, args) { + switch (method) { + case 'mdel': + return await this.deleteBranch(pool, args[0]); + } return await pool[method](...args); },