mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-30 08:20:33 +00:00
perf(redis): speed up key browser scans (#256)
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user