fix: key count may not update after soft delete key

This commit is contained in:
Lykin 2024-01-03 17:58:21 +08:00
parent 37efe5e72a
commit 1340f911c8
2 changed files with 7 additions and 3 deletions

View File

@ -83,7 +83,7 @@ export class RedisServerState {
* @param {number} updateVal * @param {number} updateVal
*/ */
updateDBKeyCount(db, updateVal) { updateDBKeyCount(db, updateVal) {
const dbInst = this.databases[this.db] const dbInst = this.databases[db]
if (dbInst != null) { if (dbInst != null) {
dbInst.maxKeys = Math.max(0, dbInst.maxKeys + updateVal) dbInst.maxKeys = Math.max(0, dbInst.maxKeys + updateVal)
} }
@ -288,6 +288,11 @@ export class RedisServerState {
// clear all key nodes // clear all key nodes
this.nodeMap.clear() this.nodeMap.clear()
this.getRoot() this.getRoot()
const dbInst = this.databases[this.db]
if (dbInst != null) {
dbInst.maxKeys = 0
dbInst.keyCount = 0
}
} else { } else {
const keyParts = split(key, this.separator) const keyParts = split(key, this.separator)
const totalParts = size(keyParts) const totalParts = size(keyParts)

View File

@ -1493,7 +1493,7 @@ const useBrowserStore = defineStore('browser', {
*/ */
async deleteKey(server, db, key, soft) { async deleteKey(server, db, key, soft) {
try { try {
let deleteCount = 0 let deleteCount = 1
if (soft !== true) { if (soft !== true) {
const { data } = await DeleteKey(server, db, key) const { data } = await DeleteKey(server, db, key)
deleteCount = get(data, 'deleteCount', 0) deleteCount = get(data, 'deleteCount', 0)
@ -1717,7 +1717,6 @@ const useBrowserStore = defineStore('browser', {
if (serverInst != null) { if (serverInst != null) {
// update tree view data // update tree view data
serverInst.removeKeyNode() serverInst.removeKeyNode()
serverInst.setDBKeyCount(db, 0)
} }
// set tab content empty // set tab content empty
const tab = useTabStore() const tab = useTabStore()