perf(redis): speed up key browser scans (#256)

This commit is contained in:
yavon007
2026-05-14 02:21:53 +08:00
committed by GitHub
parent 433297e549
commit eefa054778
2 changed files with 24 additions and 99 deletions
+11 -5
View File
@@ -304,7 +304,8 @@ function typeColor(type: string): string {
}
}
function formatSize(size: number, type: string): string {
function formatSize(size: number, type: string, valuePreview: string): string {
if (!valuePreview) return "";
if (type === "string") {
if (size >= 1024) return `${(size / 1024).toFixed(1)} KB`;
return `${size} B`;
@@ -312,6 +313,11 @@ function formatSize(size: number, type: string): string {
return String(size);
}
function formatTtl(ttl: number): string {
if (ttl === -2) return "";
return ttl === -1 ? "∞" : `${ttl}s`;
}
let searchTimer: ReturnType<typeof setTimeout> | null = null;
function onSearchInput() {
@@ -519,14 +525,14 @@ defineExpose({ focusSearch });
<!-- Size column -->
<div class="px-2 flex items-center justify-end border-r text-muted-foreground">
<template v-if="row.node.kind === 'leaf'">{{ formatSize(row.node.size, row.node.keyType) }}</template>
<template v-if="row.node.kind === 'leaf'">
{{ formatSize(row.node.size, row.node.keyType, row.node.valuePreview) }}
</template>
</div>
<!-- TTL column -->
<div class="px-2 flex items-center justify-end text-muted-foreground">
<template v-if="row.node.kind === 'leaf'">{{
row.node.ttl === -1 ? "∞" : `${row.node.ttl}s`
}}</template>
<template v-if="row.node.kind === 'leaf'">{{ formatTtl(row.node.ttl) }}</template>
</div>
</div>
</template>