feat(phase4e): batch delete with multi-select
- KeyList: multi-select mode with checkbox toggle - Batch delete bar shows selected count + delete button - RedisService: batchDelete using pipeline - Preload: batchDelete IPC channel
This commit is contained in:
@@ -179,4 +179,7 @@ export function registerIpcHandlers(): void {
|
||||
ipcMain.handle('redis:memoryUsage', async (_e, id: string, key: string) => {
|
||||
return redisService.memoryUsage(id, key)
|
||||
})
|
||||
ipcMain.handle('redis:batchDelete', async (_e, id: string, keys: string[]) => {
|
||||
return redisService.batchDelete(id, keys)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -278,3 +278,15 @@ export async function memoryUsage(id: string, key: string): Promise<number | nul
|
||||
if (!client) throw new Error(`Client ${id} not found`)
|
||||
return client.memory('USAGE', key) as Promise<number | null>
|
||||
}
|
||||
|
||||
export async function batchDelete(id: string, keys: string[]): Promise<number> {
|
||||
const client = clients.get(id)
|
||||
if (!client) throw new Error(`Client ${id} not found`)
|
||||
if (keys.length === 0) return 0
|
||||
const pipeline = client.pipeline()
|
||||
for (const key of keys) {
|
||||
pipeline.del(key)
|
||||
}
|
||||
const results = await pipeline.exec()
|
||||
return results?.filter(([err]) => !err).length ?? 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user