feat(redis): support multiple value formats in viewer (#2766)
* feat(redis): improve value decoding and viewer formats
* fix(redis): preserve stream field/value blobs
* Revert "fix(redis): preserve stream field/value blobs"
This reverts commit 168af0619a.
This commit is contained in:
1 parent
ad9841ab77
commit
ba81fa4497
13 files changed
+2417
-685
No files matched your search
@@ -26,7 +26,7 @@ import { buildRedisKeyTree, collectExpandedGroupIds, collectRedisGroupKeyRaws, f
|
||||
import { classifyRedisCommandSafety } from "@/lib/redis/redisCommandSafety";
|
||||
import { isRedisMutatingCommand } from "@/lib/redis/redisCommandTable";
|
||||
import { isRedisClearScreenCommand, nextRedisCommandDb, redisKeyTextToRaw } from "@/lib/redis/redisCommandSession";
|
||||
import { formatRedisConsoleValue, formatRedisStringValue } from "@/lib/redis/redisValuePresentation";
|
||||
import { formatRedisConsoleValue, redisValuePreview, redisValueSize } from "@/lib/redis/redisValuePresentation";
|
||||
import { isCancelSearchShortcut } from "@/lib/editor/keyboardShortcuts";
|
||||
import { copyToClipboard } from "@/lib/common/clipboard";
|
||||
import { useEditorFontFamilyStyle } from "@/composables/useEditorFontFamilyStyle";
|
||||
@@ -388,10 +388,10 @@ function redisValueToKeyInfo(value: RedisValue): RedisKeyInfo {
|
||||
return {
|
||||
key_display: value.key_display,
|
||||
key_raw: value.key_raw,
|
||||
key_type: value.key_type,
|
||||
key_type: value.redis_type,
|
||||
ttl: value.ttl,
|
||||
size: typeof value.value === "string" ? value.value.length : (value.total ?? 0),
|
||||
value_preview: createdKeyPreview(value.value),
|
||||
size: redisValueSize(value),
|
||||
value_preview: redisValuePreview(value),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -642,23 +642,14 @@ function openCreateKeyDialog() {
|
||||
showCreateKeyDialog.value = true;
|
||||
}
|
||||
|
||||
function createdKeyPreview(value: any): string {
|
||||
if (typeof value === "string") {
|
||||
const text = formatRedisStringValue(value).replace(/\s+/g, " ").trim();
|
||||
return text.length > 160 ? `${text.slice(0, 160)}…` : text;
|
||||
}
|
||||
if (Array.isArray(value) && value.length > 0) return String(value.length);
|
||||
return "";
|
||||
}
|
||||
|
||||
function upsertCreatedKey(value: any) {
|
||||
function upsertCreatedKey(value: RedisValue) {
|
||||
const keyInfo: RedisKeyInfo = {
|
||||
key_display: value.key_display,
|
||||
key_raw: value.key_raw,
|
||||
key_type: value.key_type,
|
||||
key_type: value.redis_type,
|
||||
ttl: value.ttl,
|
||||
size: typeof value.value === "string" ? value.value.length : (value.total ?? 0),
|
||||
value_preview: createdKeyPreview(value.value),
|
||||
size: redisValueSize(value),
|
||||
value_preview: redisValuePreview(value),
|
||||
};
|
||||
const existingIndex = flatKeys.value.findIndex((key) => key.key_raw === keyInfo.key_raw);
|
||||
if (existingIndex >= 0) {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user