25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
feat(redis): batch key expiry updates
jearhe774f175c3394
diff --git a/apps/desktop/src/components/redis/RedisKeyBrowser.expansion.spec.ts b/apps/desktop/src/components/redis/RedisKeyBrowser.expansion.spec.tsindex 0b31ea8a20..58e5843d57 100644--- a/apps/desktop/src/components/redis/RedisKeyBrowser.expansion.spec.ts+++ b/apps/desktop/src/components/redis/RedisKeyBrowser.expansion.spec.ts@@ -17,6 +17,8 @@ const mocks = vi.hoisted(() => ({redisStreamAdd: vi.fn(),redisSetTtl: vi.fn(),redisSetExpireAt: vi.fn(),+ redisSetKeysTtl: vi.fn(),+ redisSetKeysExpireAt: vi.fn(),redisCheckJsonModule: vi.fn(),redisDeleteKey: vi.fn(),redisDeleteKeys: vi.fn(),@@ -45,6 +47,8 @@ vi.mock("@/lib/backend/api", () => ({redisStreamAdd: mocks.redisStreamAdd,redisSetTtl: mocks.redisSetTtl,redisSetExpireAt: mocks.redisSetExpireAt,+ redisSetKeysTtl: mocks.redisSetKeysTtl,+ redisSetKeysExpireAt: mocks.redisSetKeysExpireAt,redisCheckJsonModule: mocks.redisCheckJsonModule,redisDeleteKey: mocks.redisDeleteKey,redisDeleteKeys: mocks.redisDeleteKeys,diff --git a/apps/desktop/src/components/redis/RedisKeyBrowser.expiry.spec.ts b/apps/desktop/src/components/redis/RedisKeyBrowser.expiry.spec.tsindex 45496576a9..146034eca7 100644--- a/apps/desktop/src/components/redis/RedisKeyBrowser.expiry.spec.ts+++ b/apps/desktop/src/components/redis/RedisKeyBrowser.expiry.spec.ts@@ -19,6 +19,8 @@ const mocks = vi.hoisted(() => ({redisStreamAdd: vi.fn(),redisSetTtl: vi.fn(),redisSetExpireAt: vi.fn(),+ redisSetKeysTtl: vi.fn(),+ redisSetKeysExpireAt: vi.fn(),redisCheckJsonModule: vi.fn(),redisDeleteKey: vi.fn(),redisDeleteKeys: vi.fn(),@@ -58,6 +60,8 @@ vi.mock("@/lib/backend/api", () => ({redisStreamAdd: mocks.redisStreamAdd,redisSetTtl: mocks.redisSetTtl,redisSetExpireAt: mocks.redisSetExpireAt,+ redisSetKeysTtl: mocks.redisSetKeysTtl,+ redisSetKeysExpireAt: mocks.redisSetKeysExpireAt,redisCheckJsonModule: mocks.redisCheckJsonModule,redisDeleteKey: mocks.redisDeleteKey,redisDeleteKeys: mocks.redisDeleteKeys,@@ -491,6 +495,8 @@ function resetApiMocks() {mocks.redisStreamAdd.mockResolvedValue(undefined);mocks.redisSetTtl.mockResolvedValue(undefined);mocks.redisSetExpireAt.mockResolvedValue(undefined);+ mocks.redisSetKeysTtl.mockResolvedValue({ applied: 0, missing_key_raws: [] });+ mocks.redisSetKeysExpireAt.mockResolvedValue({ applied: 0, missing_key_raws: [] });mocks.redisCheckJsonModule.mockResolvedValue(true);mocks.redisDeleteKey.mockResolvedValue(undefined);mocks.redisDeleteKeys.mockResolvedValue(0);@@ -518,6 +524,9 @@ function mountBrowser(withDeleteDetails = false) {redis: {deleteGroupDetails: withDeleteDetails ? "{target}\n{count} keys" : "redis.deleteGroupDetails",keys: "{count} keys",+ batchExpirySelected: "redis.batchExpirySelected",+ batchExpirySuccess: "applied {count}",+ batchExpiryPartial: "applied {success} failed {failed}",},},};@@ -1353,6 +1362,198 @@ describe("RedisKeyBrowser expiry creation", () => {});});+describe("RedisKeyBrowser batch expiration", () => {+ const batchKeys = [+ { key_display: "alpha", key_raw: "YWxwaGE=", key_type: "string", ttl: -1 },+ { key_display: "bravo", key_raw: "YnJhdm8=", key_type: "string", ttl: -1 },+ ];++ function batchExpiryButton(): HTMLButtonElement | null {+ return document.querySelector<HTMLButtonElement>("[data-redis-batch-expiry]");+ }++ async function openBatchExpiryDialog(rows = batchKeys) {+ mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: rows, total_keys: rows.length });+ mountBrowser();+ await settle();+ requiredElement<HTMLButtonElement>("[data-redis-select-all]").click();+ await settle();+ requiredElement<HTMLButtonElement>("[data-redis-batch-expiry]").click();+ await settle();+ }++ async function applyBatchExpiry() {+ requiredElement<HTMLButtonElement>("[data-redis-batch-expiry-apply]").click();+ await settle();+ }++ function rowTtlBadge(label: string): HTMLElement | null {+ return groupRow(label).querySelector<HTMLElement>("span[title]");+ }++ it("only offers the action for a non-empty selection and applies one TTL to every key", async () => {+ mocks.redisSetKeysTtl.mockResolvedValue({ applied: 2, missing_key_raws: [] });+ await openBatchExpiryDialog();++ expect(document.body.textContent).toContain("redis.batchExpirySelected");+ await select("ttl");+ await setInput("[data-redis-batch-expiry-ttl]", "3600");+ await applyBatchExpiry();++ // One request for the whole selection, never one call per key.+ expect(mocks.redisSetKeysTtl).toHaveBeenCalledTimes(1);+ expect(mocks.redisSetKeysTtl).toHaveBeenCalledWith("connection", 0, ["YWxwaGE=", "YnJhdm8="], 3600);+ expect(mocks.redisSetKeysExpireAt).not.toHaveBeenCalled();+ expect(mocks.toast).toHaveBeenCalledWith("applied 2", 3000);+ // A fully applied batch releases the selection like a completed batch delete does.+ expect(document.querySelector("[data-redis-batch-delete]")).toBeNull();+ expect(document.querySelector("[data-test-dialog]")).toBeNull();+ });++ it("applies PERSIST to every selected key when no expiry is chosen", async () => {+ mocks.redisSetKeysTtl.mockResolvedValue({ applied: 2, missing_key_raws: [] });+ await openBatchExpiryDialog();++ await applyBatchExpiry();++ expect(mocks.redisSetKeysTtl).toHaveBeenCalledWith("connection", 0, ["YWxwaGE=", "YnJhdm8="], -1);+ expect(mocks.redisSetKeysExpireAt).not.toHaveBeenCalled();+ });++ it("applies the same absolute expiration time to every selected key", async () => {+ mocks.redisSetKeysExpireAt.mockResolvedValue({ applied: 2, missing_key_raws: [] });+ await openBatchExpiryDialog();++ await select("at");+ requiredElement<HTMLButtonElement>("[data-test-absolute-date]").click();+ await settle();+ await applyBatchExpiry();++ const expireAt = calendarDateTimeToUnixSeconds(new CalendarDateTime(2030, 1, 2, 3, 4, 5));+ expect(mocks.redisSetKeysExpireAt).toHaveBeenCalledTimes(1);+ expect(mocks.redisSetKeysExpireAt).toHaveBeenCalledWith("connection", 0, ["YWxwaGE=", "YnJhdm8="], expireAt);+ expect(mocks.redisSetKeysTtl).not.toHaveBeenCalled();+ });++ it("rejects an invalid TTL before reaching the backend and keeps the dialog open", async () => {+ await openBatchExpiryDialog();++ await select("ttl");+ await setInput("[data-redis-batch-expiry-ttl]", "0");+ await applyBatchExpiry();++ expect(mocks.redisSetKeysTtl).not.toHaveBeenCalled();+ expect(mocks.toast).toHaveBeenCalledWith("redis.expiryTtlInvalid", 3000);+ expect(document.querySelector("[data-redis-batch-expiry-apply]")).not.toBeNull();+ });++ it("keeps only the keys the server did not update selected so they can be retried", async () => {+ mocks.redisSetKeysTtl.mockResolvedValueOnce({ applied: 1, missing_key_raws: ["YnJhdm8="] });+ mocks.redisSetKeysTtl.mockResolvedValueOnce({ applied: 1, missing_key_raws: [] });+ await openBatchExpiryDialog();++ await select("ttl");+ await setInput("[data-redis-batch-expiry-ttl]", "3600");+ await applyBatchExpiry();++ expect(mocks.toast).toHaveBeenCalledWith("applied 1 failed 1", 5000);+ expect(requiredElement<HTMLElement>("[data-redis-batch-delete]").textContent).toContain("1");++ // Retrying only targets the key the server missed.+ requiredElement<HTMLButtonElement>("[data-redis-batch-expiry]").click();+ await settle();+ await select("ttl");+ await setInput("[data-redis-batch-expiry-ttl]", "120");+ await applyBatchExpiry();++ expect(mocks.redisSetKeysTtl).toHaveBeenNthCalledWith(2, "connection", 0, ["YnJhdm8="], 120);+ expect(document.querySelector("[data-redis-batch-delete]")).toBeNull();+ });++ it("reports a failed chunk together with the keys an earlier chunk already updated", async () => {+ mocks.redisSetKeysTtl.mockResolvedValueOnce({ applied: 1_000, missing_key_raws: [] });+ mocks.redisSetKeysTtl.mockRejectedValueOnce(new Error("connection lost"));+ const rows = Array.from({ length: 1_001 }, (_, index) => ({+ key_display: `batch:${String(index).padStart(4, "0")}`,+ key_raw: `cmF3LWJhdGNoLS${index}`,+ key_type: "string",+ ttl: -1,+ }));+ await openBatchExpiryDialog(rows);++ await select("ttl");+ await setInput("[data-redis-batch-expiry-ttl]", "3600");+ await applyBatchExpiry();++ // Bounded chunks keep a 1001-key selection to two requests.+ expect(mocks.redisSetKeysTtl.mock.calls.map((call) => call[2].length)).toEqual([1_000, 1]);+ expect(mocks.toast).toHaveBeenCalledWith("applied 1000 failed 1", 5000);+ expect(mocks.toast).toHaveBeenCalledWith("connection lost", 5000);+ expect(requiredElement<HTMLElement>("[data-redis-batch-delete]").textContent).toContain("1");+ });++ it("does not start a second request while the batch is still running", async () => {+ const pending = deferred<{ applied: number; missing_key_raws: string[] }>();+ mocks.redisSetKeysTtl.mockReturnValue(pending.promise);+ await openBatchExpiryDialog();++ await select("ttl");+ await setInput("[data-redis-batch-expiry-ttl]", "3600");++ const applyButton = requiredElement<HTMLButtonElement>("[data-redis-batch-expiry-apply]");+ applyButton.click();+ await settle();+ applyButton.click();+ await settle();++ expect(mocks.redisSetKeysTtl).toHaveBeenCalledTimes(1);+ // A conflicting batch delete stays blocked while the expiry request owns the selection.+ expect(requiredElement<HTMLButtonElement>("[data-redis-batch-delete]").disabled).toBe(true);++ pending.resolve({ applied: 2, missing_key_raws: [] });+ await settle();+ expect(mocks.toast).toHaveBeenCalledWith("applied 2", 3000);+ });++ it("updates the loaded TTL badge without rescanning the key list", async () => {+ const rows = [{ key_display: "alpha", key_raw: "YWxwaGE=", key_type: "string", ttl: -1 }];+ mocks.redisSetKeysTtl.mockResolvedValue({ applied: 1, missing_key_raws: [] });+ await openBatchExpiryDialog(rows);++ expect(rowTtlBadge("alpha")?.textContent).toContain("redis.noExpiry");+ expect(mocks.redisScanKeysBatch).toHaveBeenCalledTimes(1);++ await select("ttl");+ await setInput("[data-redis-batch-expiry-ttl]", "3600");+ await applyBatchExpiry();++ // The applied TTL is reflected locally instead of one refresh request per key.+ expect(rowTtlBadge("alpha")?.textContent).toContain("redis.ttlHour");+ expect(rowTtlBadge("alpha")?.textContent).not.toContain("redis.noExpiry");+ expect(mocks.redisScanKeysBatch).toHaveBeenCalledTimes(1);++ // PERSIST flips the same badge back to the no-expiry label.+ requiredElement<HTMLButtonElement>("[data-redis-select-all]").click();+ await settle();+ requiredElement<HTMLButtonElement>("[data-redis-batch-expiry]").click();+ await settle();+ await applyBatchExpiry();++ expect(mocks.redisSetKeysTtl).toHaveBeenLastCalledWith("connection", 0, ["YWxwaGE="], -1);+ expect(rowTtlBadge("alpha")?.textContent).toContain("redis.noExpiry");+ expect(mocks.redisScanKeysBatch).toHaveBeenCalledTimes(1);+ });++ it("hides the action while nothing is selected", async () => {+ mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: batchKeys, total_keys: batchKeys.length });+ mountBrowser();+ await settle();++ expect(batchExpiryButton()).toBeNull();+ expect(document.querySelector("[data-redis-batch-expiry-apply]")).toBeNull();+ });+});+describe("RedisKeyBrowser fuzzy key hierarchy", () => {it("deletes a leaf directly from the key list after confirmation", async () => {const key = { key_display: "session:current", key_raw: "c2Vzc2lvbjpjdXJyZW50", key_type: "string", ttl: -1 };diff --git a/apps/desktop/src/components/redis/RedisKeyBrowser.infiniteScroll.spec.ts b/apps/desktop/src/components/redis/RedisKeyBrowser.infiniteScroll.spec.tsindex 6fa92edbad..a847bcbb38 100644--- a/apps/desktop/src/components/redis/RedisKeyBrowser.infiniteScroll.spec.ts+++ b/apps/desktop/src/components/redis/RedisKeyBrowser.infiniteScroll.spec.ts@@ -26,6 +26,8 @@ const mocks = vi.hoisted(() => ({redisStreamAdd: vi.fn(),redisSetTtl: vi.fn(),redisSetExpireAt: vi.fn(),+ redisSetKeysTtl: vi.fn(),+ redisSetKeysExpireAt: vi.fn(),redisCheckJsonModule: vi.fn(),redisDeleteKey: vi.fn(),redisDeleteKeys: vi.fn(),@@ -54,6 +56,8 @@ vi.mock("@/lib/backend/api", () => ({redisStreamAdd: mocks.redisStreamAdd,redisSetTtl: mocks.redisSetTtl,redisSetExpireAt: mocks.redisSetExpireAt,+ redisSetKeysTtl: mocks.redisSetKeysTtl,+ redisSetKeysExpireAt: mocks.redisSetKeysExpireAt,redisCheckJsonModule: mocks.redisCheckJsonModule,redisDeleteKey: mocks.redisDeleteKey,redisDeleteKeys: mocks.redisDeleteKeys,diff --git a/apps/desktop/src/components/redis/RedisKeyBrowser.searchHistory.spec.ts b/apps/desktop/src/components/redis/RedisKeyBrowser.searchHistory.spec.tsindex 439c9e1953..f9a15a97ad 100644--- a/apps/desktop/src/components/redis/RedisKeyBrowser.searchHistory.spec.ts+++ b/apps/desktop/src/components/redis/RedisKeyBrowser.searchHistory.spec.ts@@ -17,6 +17,8 @@ const mocks = vi.hoisted(() => ({redisStreamAdd: vi.fn(),redisSetTtl: vi.fn(),redisSetExpireAt: vi.fn(),+ redisSetKeysTtl: vi.fn(),+ redisSetKeysExpireAt: vi.fn(),redisCheckJsonModule: vi.fn(),redisDeleteKey: vi.fn(),redisDeleteKeys: vi.fn(),@@ -44,6 +46,8 @@ vi.mock("@/lib/backend/api", () => ({redisStreamAdd: mocks.redisStreamAdd,redisSetTtl: mocks.redisSetTtl,redisSetExpireAt: mocks.redisSetExpireAt,+ redisSetKeysTtl: mocks.redisSetKeysTtl,+ redisSetKeysExpireAt: mocks.redisSetKeysExpireAt,redisCheckJsonModule: mocks.redisCheckJsonModule,redisDeleteKey: mocks.redisDeleteKey,redisDeleteKeys: mocks.redisDeleteKeys,diff --git a/apps/desktop/src/components/redis/RedisKeyBrowser.subtreeFill.spec.ts b/apps/desktop/src/components/redis/RedisKeyBrowser.subtreeFill.spec.tsindex be92e05ba3..ac68d3591c 100644--- a/apps/desktop/src/components/redis/RedisKeyBrowser.subtreeFill.spec.ts+++ b/apps/desktop/src/components/redis/RedisKeyBrowser.subtreeFill.spec.ts@@ -17,6 +17,8 @@ const mocks = vi.hoisted(() => ({redisStreamAdd: vi.fn(),redisSetTtl: vi.fn(),redisSetExpireAt: vi.fn(),+ redisSetKeysTtl: vi.fn(),+ redisSetKeysExpireAt: vi.fn(),redisCheckJsonModule: vi.fn(),redisDeleteKey: vi.fn(),redisDeleteKeys: vi.fn(),@@ -44,6 +46,8 @@ vi.mock("@/lib/backend/api", () => ({redisStreamAdd: mocks.redisStreamAdd,redisSetTtl: mocks.redisSetTtl,redisSetExpireAt: mocks.redisSetExpireAt,+ redisSetKeysTtl: mocks.redisSetKeysTtl,+ redisSetKeysExpireAt: mocks.redisSetKeysExpireAt,redisCheckJsonModule: mocks.redisCheckJsonModule,redisDeleteKey: mocks.redisDeleteKey,redisDeleteKeys: mocks.redisDeleteKeys,diff --git a/apps/desktop/src/components/redis/RedisKeyBrowser.tabState.spec.ts b/apps/desktop/src/components/redis/RedisKeyBrowser.tabState.spec.tsindex dc789a91b3..69952638ac 100644--- a/apps/desktop/src/components/redis/RedisKeyBrowser.tabState.spec.ts+++ b/apps/desktop/src/components/redis/RedisKeyBrowser.tabState.spec.ts@@ -17,6 +17,8 @@ const mocks = vi.hoisted(() => ({redisStreamAdd: vi.fn(),redisSetTtl: vi.fn(),redisSetExpireAt: vi.fn(),+ redisSetKeysTtl: vi.fn(),+ redisSetKeysExpireAt: vi.fn(),redisCheckJsonModule: vi.fn(),redisDeleteKey: vi.fn(),redisDeleteKeys: vi.fn(),@@ -44,6 +46,8 @@ vi.mock("@/lib/backend/api", () => ({redisStreamAdd: mocks.redisStreamAdd,redisSetTtl: mocks.redisSetTtl,redisSetExpireAt: mocks.redisSetExpireAt,+ redisSetKeysTtl: mocks.redisSetKeysTtl,+ redisSetKeysExpireAt: mocks.redisSetKeysExpireAt,redisCheckJsonModule: mocks.redisCheckJsonModule,redisDeleteKey: mocks.redisDeleteKey,redisDeleteKeys: mocks.redisDeleteKeys,diff --git a/apps/desktop/src/components/redis/RedisKeyBrowser.vue b/apps/desktop/src/components/redis/RedisKeyBrowser.vueindex 1ad7c4a873..52941f9960 100644--- a/apps/desktop/src/components/redis/RedisKeyBrowser.vue+++ b/apps/desktop/src/components/redis/RedisKeyBrowser.vue@@ -65,7 +65,7 @@ import { REDIS_SCAN_PAGE_SIZE_DEFAULT } from "@/lib/redis/redisKeyPattern";import { chunkRedisKeyRaws, collectUniqueRedisKeys } from "@/lib/redis/redisKeyBatch";import { getRedisCreateKeyTypeHelp, redisCreateKeyTypeHelpOptionOnOpen, shouldActivateRedisCreateKeyTypeHelpOnFocus } from "@/lib/redis/redisCreateKeyTypeHelp";import { optionHelpPanelOffsetTop } from "@/lib/common/optionHelpPanelOffset";-import { applyRedisExpiryPolicy, type RedisExpiryMode, validateRedisExpiry } from "@/lib/redis/redisExpiry";+import { applyRedisBatchExpiryPolicy, applyRedisExpiryPolicy, type RedisExpiryMode, type RedisExpiryPolicy, validateRedisExpiry } from "@/lib/redis/redisExpiry";import { shouldLoadMoreRedisKeys } from "@/lib/redis/redisKeyInfiniteScroll";import { formatTtl } from "@/lib/common/ttlFormat";import { computeTtlCountdownValue } from "@/lib/redis/redisAutoRefresh";@@ -136,6 +136,11 @@ const redisExpiryTransport = {setExpireAt: api.redisSetExpireAt,};+const redisBatchExpiryTransport = {+ setKeysTtl: api.redisSetKeysTtl,+ setKeysExpireAt: api.redisSetKeysExpireAt,+};+const flatKeys = shallowRef<RedisKeyInfo[]>([]);const treeKeys = shallowRef<RedisKeyTreeNode[]>([]);let flatKeyByRaw = new Map<string, RedisKeyInfo>();@@ -178,6 +183,13 @@ const noExpiryProjectionEpoch = ref(0);const selectionAnchorRowId = ref<string | null>(null);const selectedGroupLeafCounts = shallowRef<Map<string, number>>(new Map());const deletingKeys = ref(false);+const showBatchExpiryDialog = ref(false);+const savingBatchExpiry = ref(false);+const batchExpiryMode = ref<RedisExpiryMode>("none");+const batchExpiryTtl = ref("");+const batchExpiryExpireAt = shallowRef<CalendarDateTime | null>(null);+/** Snapshot taken when the dialog opens so a background refresh cannot retarget the batch. */+const batchExpiryKeyRaws = shallowRef<string[]>([]);const pendingDanger = ref<{ kind: "delete-keys"; title: string; keyRaws: string[]; loadedSearchResults: boolean } | { kind: "command"; command: string } | null>(null);const showDangerConfirm = ref(false);const commandText = ref("");@@ -293,7 +305,9 @@ const isFuzzyKeySearch = computed(() => searchMode.value === "key" && isSearchMoconst fuzzyTreeLimitReached = computed(() => isFuzzyKeySearch.value && !canBuildRedisFuzzyTree(flatKeys.value.length));const useFlatKeySearchRows = computed(() => showCustomGrouping.value || (searchMode.value === "key" && isSearchMode.value && !fuzzyKeySearch.value) || fuzzyTreeLimitReached.value);const isFuzzyHierarchyView = computed(() => isFuzzyKeySearch.value && !fuzzyTreeLimitReached.value);-const selectionBusy = computed(() => deletingKeys.value || loading.value || loadingMore.value || isFetchingAll.value || searchPending.value);+/** True while a key-list mutation (delete or batch expiry) owns the visible result set. */+const mutatingKeys = computed(() => deletingKeys.value || savingBatchExpiry.value);+const selectionBusy = computed(() => mutatingKeys.value || loading.value || loadingMore.value || isFetchingAll.value || searchPending.value);// checkedKeys is always a subset of loaded keys, so size equality is enough.const allLoadedKeysSelected = computed(() => flatKeys.value.length > 0 && checkedKeys.value.size === flatKeys.value.length);const allKeysSelected = computed(() => (customGrouping.value.enabled ? filteredFlatKeys.value.length > 0 && checkedKeys.value.size === filteredFlatKeys.value.length : allLoadedKeysSelected.value && !hasMore.value));@@ -1142,7 +1156,7 @@ function onRedisKeyScroll(event: Event) {const shouldLoad = shouldLoadMoreRedisKeys({enabled: redisInfiniteScrollEnabled.value,hasMore: hasMore.value,- busy: loading.value || loadingMore.value || searchPending.value || deletingKeys.value || isFetchingAll.value,+ busy: loading.value || loadingMore.value || searchPending.value || mutatingKeys.value || isFetchingAll.value,loadedKeys: flatKeys.value.length,maxKeys: redisInfiniteScrollMaxKeys.value,scrollTop: scroller.scrollTop,@@ -1789,6 +1803,116 @@ function scrollCommandTerminalToEnd() {});}+// ---------------------------------------------------------------------------+// Batch expiration+// ---------------------------------------------------------------------------++/** Keeps only the given loaded keys checked, so a partial batch failure can be retried. */+function retainCheckedKeys(keyRaws: Iterable<string>) {+ const keep = new Set(keyRaws);+ const nextChecked = new Set<string>();+ for (const keyRaw of checkedKeys.value) {+ if (keep.has(keyRaw) && loadedKeyRaws.has(keyRaw)) nextChecked.add(keyRaw);+ }+ checkedKeys.value = nextChecked;+ selectedGroupLeafCounts.value = groupLeafCountsFromChecked(nextChecked);+ selectionEpoch.value++;+}++/**+ * Writes a server-confirmed TTL straight into one loaded row, and reports+ * whether its no-expiry membership changed.+ *+ * The batch result already carries the applied TTL, so the list badge and its+ * countdown update without one refresh request per key.+ */+function applyKeyTtlMetadata(keyRaw: string, ttl: number): boolean {+ const keyInfo = flatKeyByRaw.get(keyRaw);+ if (!keyInfo) return false;+ const previousTtl = keyInfo.ttl ?? -2;+ const nextKeyInfo: RedisKeyInfo = { ...keyInfo, ttl };+ if (!updateRedisKeyInfoMetadataByRaw(flatKeyByRaw, nextKeyInfo)) return false;+ recordKeyTtlObservedAt(nextKeyInfo);+ if (treeIndex) updateRedisKeyTreeLeafMetadata(treeIndex, nextKeyInfo);+ return (previousTtl === -1) !== (ttl === -1);+}++function applyBatchExpiryMetadata(keyRaws: readonly string[], policy: RedisExpiryPolicy) {+ const nowSeconds = Math.ceil(Date.now() / 1_000);+ let noExpiryMembershipChanged = false;++ for (const keyRaw of keyRaws) {+ if (policy.mode === "at") {+ const remaining = policy.expireAt - nowSeconds;+ // EXPIREAT with an already-past timestamp deletes the key instead of expiring it.+ if (remaining <= 0) {+ onKeyDeleted(keyRaw);+ continue;+ }+ if (applyKeyTtlMetadata(keyRaw, remaining)) noExpiryMembershipChanged = true;+ continue;+ }+ if (applyKeyTtlMetadata(keyRaw, policy.mode === "ttl" ? policy.ttl : -1)) noExpiryMembershipChanged = true;+ }++ // Publish one metadata refresh for the whole batch: a 1000-key selection must+ // not schedule 1000 reactive updates or 1000 countdown-timer re-checks.+ if (noExpiryMembershipChanged) noExpiryProjectionEpoch.value++;+ keyMetadataEpoch.value++;+ syncListTtlTimer();+}++function openBatchExpiryDialog() {+ if (checkedKeys.value.size === 0 || selectionBusy.value) return;+ batchExpiryKeyRaws.value = [...checkedKeys.value];+ batchExpiryMode.value = "none";+ batchExpiryTtl.value = "";+ batchExpiryExpireAt.value = null;+ showBatchExpiryDialog.value = true;+}++function onBatchExpiryDialogOpenChange(open: boolean) {+ if (!open && savingBatchExpiry.value) return;+ showBatchExpiryDialog.value = open;+}++async function saveBatchExpiry() {+ if (savingBatchExpiry.value || batchExpiryKeyRaws.value.length === 0) return;+ const validation = validateRedisExpiry(batchExpiryMode.value, batchExpiryTtl.value, batchExpiryExpireAt.value);+ if (!validation.valid) {+ toast(expiryValidationMessage(validation.reason), 3000);+ return;+ }++ const keyRaws = batchExpiryKeyRaws.value;+ savingBatchExpiry.value = true;+ try {+ const summary = await applyRedisBatchExpiryPolicy(redisBatchExpiryTransport, props.connectionId, props.db, keyRaws, validation.policy);+ const failed = new Set(summary.failedKeyRaws);+ applyBatchExpiryMetadata(+ keyRaws.filter((keyRaw) => !failed.has(keyRaw)),+ validation.policy,+ );++ if (failed.size > 0) {+ // Keep only the keys that were not updated so the user can retry them directly.+ retainCheckedKeys(failed);+ toast(t("redis.batchExpiryPartial", { success: summary.applied, failed: failed.size }), 5000);+ } else {+ resetCheckedKeys();+ toast(t("redis.batchExpirySuccess", { count: summary.applied }), 3000);+ }+ // Surface the underlying cause as well; the count toast above keeps the partial result.+ if (summary.errors.length > 0) toast(summary.errors[0], 5000);+ } catch (error) {+ toast(errorMessage(error), 5000);+ } finally {+ savingBatchExpiry.value = false;+ showBatchExpiryDialog.value = false;+ batchExpiryKeyRaws.value = [];+ }+}+function appendCommandHistory(entry: Omit<RedisCommandHistoryEntry, "id">): number {const id = ++commandHistoryId;commandHistory.value = [...commandHistory.value, { id, ...entry }];@@ -3044,8 +3168,9 @@ defineExpose({ focusSearch, insertCommand, executeCommand: executeAiCommand });>{{ customGrouping.enabled ? t("redisGrouping.selectLoaded") : t("redis.selectAllLoaded") }}</Button><Button v-if="checkedKeys.size > 0" variant="ghost" size="sm" class="h-6 shrink-0 px-1.5 text-xs" :disabled="selectionBusy" data-redis-deselect-all @click="clearAllCheckedKeys">{{ t("redis.deselectAll") }}</Button>+ <Button v-if="checkedKeys.size > 0" variant="ghost" size="sm" class="h-6 shrink-0 px-1.5 text-xs" :disabled="selectionBusy" :title="t('redis.batchExpiry')" data-redis-batch-expiry @click="openBatchExpiryDialog"><Clock class="w-3 h-3 mr-1" />{{ t("redis.batchExpiry") }}</Button><Button v-if="checkedKeys.size > 0" variant="ghost" size="sm" class="h-6 shrink-0 text-xs text-destructive" :disabled="selectionBusy" data-redis-batch-delete @click="requestBatchDelete"><Trash2 class="w-3 h-3 mr-1" />{{ checkedKeys.size }}</Button>- <Button variant="ghost" size="icon" class="h-6 w-6 shrink-0" :disabled="deletingKeys || loading || loadingMore || isFetchingAll" @click="loadKeys">+ <Button variant="ghost" size="icon" class="h-6 w-6 shrink-0" :disabled="mutatingKeys || loading || loadingMore || isFetchingAll" @click="loadKeys"><Loader2 v-if="loading" class="h-3 w-3 animate-spin" /><RefreshCw v-else class="h-3 w-3" /></Button>@@ -3204,7 +3329,7 @@ defineExpose({ focusSearch, insertCommand, executeCommand: executeAiCommand });<div v-else-if="flatKeys.length === 0 && !loading" class="flex-1 flex flex-col items-center justify-center text-muted-foreground text-xs p-4 text-center"><template v-if="hasMore"><span class="mb-3">{{ t("redis.noKeysInScanHint") }}</span>- <Button variant="outline" size="sm" class="h-7 text-xs" :disabled="loadingMore || searchPending || deletingKeys" @click="loadMore()">+ <Button variant="outline" size="sm" class="h-7 text-xs" :disabled="loadingMore || searchPending || mutatingKeys" @click="loadMore()"><Loader2 v-if="loadingMore" class="w-3 h-3 mr-1.5 animate-spin" />{{ t("redis.loadMoreKeys") }}</Button>@@ -3303,11 +3428,11 @@ defineExpose({ focusSearch, insertCommand, executeCommand: executeAiCommand });{{ t("redis.fuzzyTreeLimit", { count: flatKeys.length }) }}</div><div v-if="hasMore && !isFetchingAll" class="shrink-0 border-t px-2 py-1.5 flex items-center gap-1.5">- <Button variant="outline" size="sm" class="h-7 text-xs flex-1" :disabled="loadingMore || loading || searchPending || deletingKeys" @click="loadMore()">+ <Button variant="outline" size="sm" class="h-7 text-xs flex-1" :disabled="loadingMore || loading || searchPending || mutatingKeys" @click="loadMore()"><Loader2 v-if="loadingMore" class="w-3 h-3 mr-1.5 animate-spin" />{{ t("redis.loadMoreKeys") }}</Button>- <Button variant="outline" size="sm" class="h-7 text-xs flex-1" :disabled="loading || searchPending || deletingKeys || !hasMore" @click="fetchAll">+ <Button variant="outline" size="sm" class="h-7 text-xs flex-1" :disabled="loading || searchPending || mutatingKeys || !hasMore" @click="fetchAll">{{ t("redis.fetchAllKeys") }}</Button></div>@@ -3315,7 +3440,7 @@ defineExpose({ focusSearch, insertCommand, executeCommand: executeAiCommand });<div class="text-xs text-muted-foreground text-center">{{ fetchAllProgressText }}</div>- <Button variant="destructive" size="sm" class="h-7 text-xs w-full" :disabled="fetchAllStopRequested || deletingKeys" @click="stopFetchAll">+ <Button variant="destructive" size="sm" class="h-7 text-xs w-full" :disabled="fetchAllStopRequested || mutatingKeys" @click="stopFetchAll">{{ t("redis.stopFetchAll") }}</Button></div>@@ -3454,6 +3579,49 @@ defineExpose({ focusSearch, insertCommand, executeCommand: executeAiCommand });<DangerConfirmDialog v-model:open="showDangerConfirm" :message="dangerMessage" :details="dangerDetails" :confirm-label="dangerConfirmLabel" :loading="deletingKeys" :close-on-confirm="pendingDanger?.kind !== 'delete-keys'" @confirm="applyDangerAction" />+ <Dialog :open="showBatchExpiryDialog" @update:open="onBatchExpiryDialogOpenChange">+ <DialogContent class="sm:max-w-[420px]">+ <DialogHeader>+ <DialogTitle>{{ t("redis.batchExpiryTitle") }}</DialogTitle>+ </DialogHeader>++ <div class="grid gap-3">+ <p v-if="batchExpiryKeyRaws.length > 0" class="text-xs text-muted-foreground">{{ t("redis.batchExpirySelected", { count: batchExpiryKeyRaws.length }) }}</p>+ <div class="grid gap-1.5 text-xs font-medium">+ <span>{{ t("redis.expiry") }}</span>+ <Select v-model="batchExpiryMode" :disabled="savingBatchExpiry">+ <SelectTrigger class="h-8 text-xs" data-redis-batch-expiry-mode>+ <SelectValue />+ </SelectTrigger>+ <SelectContent data-redis-expiry-mode-content>+ <SelectItem value="none">{{ t("redis.expiryNone") }}</SelectItem>+ <SelectItem value="ttl">{{ t("redis.expiryTtl") }}</SelectItem>+ <SelectItem value="at">{{ t("redis.expiryAt") }}</SelectItem>+ </SelectContent>+ </Select>+ <label v-if="batchExpiryMode === 'ttl'" class="grid gap-1.5 text-xs font-medium">+ <span>{{ t("redis.createKeyTtl") }}</span>+ <Input v-model="batchExpiryTtl" data-redis-batch-expiry-ttl class="dbx-editor-font-family h-8 text-xs" :disabled="savingBatchExpiry" inputmode="numeric" :placeholder="t('redis.createKeyTtlPlaceholder')" @keydown.enter="saveBatchExpiry" />+ </label>+ <label v-else-if="batchExpiryMode === 'at'" class="grid gap-1.5 text-xs font-medium">+ <span>{{ t("redis.expiryAt") }}</span>+ <DateTimePicker v-model="batchExpiryExpireAt" full-width :locale="locale" :disabled="savingBatchExpiry" />+ </label>+ </div>+ </div>++ <DialogFooter>+ <Button variant="ghost" :disabled="savingBatchExpiry" @click="showBatchExpiryDialog = false">+ {{ t("dangerDialog.cancel") }}+ </Button>+ <Button :disabled="savingBatchExpiry || batchExpiryKeyRaws.length === 0" data-redis-batch-expiry-apply @click="saveBatchExpiry">+ <Loader2 v-if="savingBatchExpiry" class="h-4 w-4 animate-spin" />+ {{ t("redis.batchExpiryApply") }}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+<Dialog :open="showCreateKeyDialog" @update:open="onCreateKeyDialogOpenChange"><DialogContent class="sm:max-w-md" :show-close-button="!creatingKey" :style="editorFontFamilyStyle"><DialogHeader>diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.tsindex f988bcf6a1..c0ab271b93 100644--- a/apps/desktop/src/i18n/locales/az.ts+++ b/apps/desktop/src/i18n/locales/az.ts@@ -5147,6 +5147,12 @@ export default withEnglishFallback({deleteKey: "Açarı sil",deleteGroupDetails: "{target}\n{count} açar",deleteLoadedSearchKeysDetails: "{target}\n{count} yüklənmiş uyğun açar",+ batchExpiry: "Müddəti təyin et",+ batchExpiryTitle: "Toplu müddət təyini",+ batchExpirySelected: "{count} açar seçildi",+ batchExpiryApply: "Tətbiq et",+ batchExpirySuccess: "{count} açar üçün müddət təyin edildi",+ batchExpiryPartial: "{success} uğurlu, {failed} uğursuz",flushDb: "Cari verilənlər bazasını təmizlə",flushDbMessage: "Bu əməliyyat cari Redis verilənlər bazasındakı bütün açarları siləcək və geri qaytarıla bilməz. Davam edilsin?",flushDbDetails: "Hədəf: Redis db{db}\nƏhatə dairəsi: cari verilənlər bazasındakı bütün açarlar",diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex 8a5b0bd93d..cf27a3a441 100644--- a/apps/desktop/src/i18n/locales/en.ts+++ b/apps/desktop/src/i18n/locales/en.ts@@ -5145,6 +5145,12 @@ export default {deleteKey: "Delete key",deleteGroupDetails: "{target}\n{count} keys",deleteLoadedSearchKeysDetails: "{target}\n{count} loaded matching keys",+ batchExpiry: "Set expiry",+ batchExpiryTitle: "Batch expiration",+ batchExpirySelected: "Selected {count} keys",+ batchExpiryApply: "Apply",+ batchExpirySuccess: "Expiration applied to {count} keys",+ batchExpiryPartial: "{success} applied, {failed} not applied",flushDb: "Clear current DB",flushDbMessage: "This will delete every key in the current Redis database and cannot be undone. Continue?",flushDbDetails: "Target: Redis db{db}\nScope: all keys in the current DB",diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.tsindex 152bfeeb8a..b732bc2571 100644--- a/apps/desktop/src/i18n/locales/es.ts+++ b/apps/desktop/src/i18n/locales/es.ts@@ -4857,6 +4857,12 @@ export default withEnglishFallback({deleteKey: "Eliminar clave",deleteGroupDetails: "{target}\n{count} claves",deleteLoadedSearchKeysDetails: "{target}\n{count} claves coincidentes cargadas",+ batchExpiry: "Establecer caducidad",+ batchExpiryTitle: "Caducidad por lotes",+ batchExpirySelected: "{count} claves seleccionadas",+ batchExpiryApply: "Aplicar",+ batchExpirySuccess: "Caducidad aplicada a {count} claves",+ batchExpiryPartial: "{success} aplicadas, {failed} sin aplicar",flushDb: "Limpiar DB actual",flushDbMessage: "Esto eliminará todas las claves de la base de datos Redis actual y no se puede deshacer. ¿Continuar?",flushDbDetails: "Destino: Redis db{db}\nAlcance: todas las claves de la DB actual",diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.tsindex 8444118f9f..4567daa020 100644--- a/apps/desktop/src/i18n/locales/it.ts+++ b/apps/desktop/src/i18n/locales/it.ts@@ -4855,6 +4855,12 @@ export default withEnglishFallback({deleteKey: "Elimina chiave",deleteGroupDetails: "{target}\n{count} chiavi",deleteLoadedSearchKeysDetails: "{target}\n{count} chiavi corrispondenti caricate",+ batchExpiry: "Imposta scadenza",+ batchExpiryTitle: "Scadenza in blocco",+ batchExpirySelected: "{count} chiavi selezionate",+ batchExpiryApply: "Applica",+ batchExpirySuccess: "Scadenza applicata a {count} chiavi",+ batchExpiryPartial: "{success} applicate, {failed} non applicate",flushDb: "Pulisci DB corrente",flushDbMessage: "Questo eliminerà ogni chiave nel database Redis corrente e non può essere annullato. Continuare?",flushDbDetails: "Destinazione: Redis db{db}\nAmbito: tutte le chiavi nel DB corrente",diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.tsindex 6e73638bfa..d5b2bc96ba 100644--- a/apps/desktop/src/i18n/locales/ja.ts+++ b/apps/desktop/src/i18n/locales/ja.ts@@ -4884,6 +4884,12 @@ export default withEnglishFallback({deleteKey: "キーを削除",deleteGroupDetails: "{target}\n{count}個のキー",deleteLoadedSearchKeysDetails: "{target}\n読み込み済みの一致キー {count} 件",+ batchExpiry: "有効期限を設定",+ batchExpiryTitle: "有効期限の一括設定",+ batchExpirySelected: "{count} 件のキーを選択中",+ batchExpiryApply: "適用",+ batchExpirySuccess: "{count} 件のキーに有効期限を設定しました",+ batchExpiryPartial: "成功 {success} 件、失敗 {failed} 件",flushDb: "現在のDBをクリア",flushDbMessage: "現在のRedisデータベース内のすべてのキーが削除されます。この操作は取り消せません。続行しますか?",flushDbDetails: "対象: Redis db{db}\n範囲: 現在のDB内のすべてのキー",diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.tsindex ecd704f177..6507c3be2d 100644--- a/apps/desktop/src/i18n/locales/ko.ts+++ b/apps/desktop/src/i18n/locales/ko.ts@@ -4478,6 +4478,12 @@ export default withEnglishFallback({deleteKey: "키 삭제",deleteGroupDetails: "{target}\n키 {count}개",deleteLoadedSearchKeysDetails: "{target}\n로드된 일치 키 {count}개",+ batchExpiry: "만료 시간 설정",+ batchExpiryTitle: "만료 시간 일괄 설정",+ batchExpirySelected: "키 {count}개 선택됨",+ batchExpiryApply: "적용",+ batchExpirySuccess: "키 {count}개에 만료 시간을 설정했습니다",+ batchExpiryPartial: "성공 {success}개, 실패 {failed}개",flushDb: "현재 DB 비우기",flushDbMessage: "현재 Redis 데이터베이스의 모든 키를 삭제하며 되돌릴 수 없습니다. 계속하시겠습니까?",flushDbDetails: "대상: Redis db{db}\n범위: 현재 DB의 모든 키",diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.tsindex ca3e32c948..1c1347f788 100644--- a/apps/desktop/src/i18n/locales/pt-BR.ts+++ b/apps/desktop/src/i18n/locales/pt-BR.ts@@ -4857,6 +4857,12 @@ export default withEnglishFallback({deleteKey: "Excluir chave",deleteGroupDetails: "{target}\n{count} chaves",deleteLoadedSearchKeysDetails: "{target}\n{count} chaves correspondentes carregadas",+ batchExpiry: "Definir expiração",+ batchExpiryTitle: "Expiração em lote",+ batchExpirySelected: "{count} chaves selecionadas",+ batchExpiryApply: "Aplicar",+ batchExpirySuccess: "Expiração aplicada a {count} chaves",+ batchExpiryPartial: "{success} aplicadas, {failed} não aplicadas",flushDb: "Limpar DB atual",flushDbMessage: "Isto excluirá todas as chaves do banco de dados Redis atual e não pode ser desfeito. Continuar?",flushDbDetails: "Alvo: Redis db{db}\nEscopo: todas as chaves do DB atual",diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.tsindex 07f963f02a..422adc89da 100644--- a/apps/desktop/src/i18n/locales/tr.ts+++ b/apps/desktop/src/i18n/locales/tr.ts@@ -5041,6 +5041,12 @@ export default withEnglishFallback({deleteKey: "Anahtarı sil",deleteGroupDetails: "{target}\n{count} anahtar",deleteLoadedSearchKeysDetails: "{target}\n{count} yüklenmiş eşleşen anahtar",+ batchExpiry: "Süre belirle",+ batchExpiryTitle: "Toplu süre belirleme",+ batchExpirySelected: "{count} anahtar seçildi",+ batchExpiryApply: "Uygula",+ batchExpirySuccess: "{count} anahtara süre uygulandı",+ batchExpiryPartial: "{success} başarılı, {failed} başarısız",flushDb: "Geçerli VT'yi temizle",flushDbMessage: "Bu işlem geçerli Redis veritabanındaki her anahtarı siler ve geri alınamaz. Devam edilsin mi?",flushDbDetails: "Hedef: Redis db{db}\nKapsam: geçerli VT'deki tüm anahtarlar",diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.tsindex f30bc5fba0..d4dd6d8e1d 100644--- a/apps/desktop/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/src/i18n/locales/zh-CN.ts@@ -5129,6 +5129,12 @@ export default withEnglishFallback({deleteKey: "删除 key",deleteGroupDetails: "{target}\n{count} 个 key",deleteLoadedSearchKeysDetails: "{target}\n已加载的 {count} 个匹配 key",+ batchExpiry: "设置过期时间",+ batchExpiryTitle: "批量设置过期时间",+ batchExpirySelected: "已选择 {count} 个 key",+ batchExpiryApply: "应用",+ batchExpirySuccess: "已为 {count} 个 key 设置过期时间",+ batchExpiryPartial: "成功 {success} 个,失败 {failed} 个",flushDb: "清空当前 DB",flushDbMessage: "这会删除当前 Redis 数据库中的所有 key,且不可撤销。确认继续?",flushDbDetails: "目标: Redis db{db}\n范围: 当前 DB 的所有 key",diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.tsindex 6229cd4ee7..e6aa88a067 100644--- a/apps/desktop/src/i18n/locales/zh-TW.ts+++ b/apps/desktop/src/i18n/locales/zh-TW.ts@@ -4177,6 +4177,12 @@ export default withEnglishFallback({deleteKey: "刪除 key",deleteGroupDetails: "{target}\n{count} 個 key",deleteLoadedSearchKeysDetails: "{target}\n已載入的 {count} 個相符 key",+ batchExpiry: "設定過期時間",+ batchExpiryTitle: "批次設定過期時間",+ batchExpirySelected: "已選取 {count} 個 key",+ batchExpiryApply: "套用",+ batchExpirySuccess: "已為 {count} 個 key 設定過期時間",+ batchExpiryPartial: "成功 {success} 個,失敗 {failed} 個",flushDb: "清空目前 DB",flushDbMessage: "這會刪除目前 Redis 資料庫中的所有 key,且無法復原。確認繼續?",flushDbDetails: "目標: Redis db{db}\n範圍: 目前 DB 的所有 key",diff --git a/apps/desktop/src/lib/__tests__/redis/RedisExpiryWiring.spec.ts b/apps/desktop/src/lib/__tests__/redis/RedisExpiryWiring.spec.tsindex 90b72b15b5..3cce2f72b7 100644--- a/apps/desktop/src/lib/__tests__/redis/RedisExpiryWiring.spec.ts+++ b/apps/desktop/src/lib/__tests__/redis/RedisExpiryWiring.spec.ts@@ -6,11 +6,14 @@ import { describe, expect, it } from "vitest";const browserSource = readFileSync(new URL("../../../components/redis/RedisKeyBrowser.vue", import.meta.url), "utf8");const viewerSource = readFileSync(new URL("../../../components/redis/RedisValueViewer.vue", import.meta.url), "utf8");const localeSources = {+ az: readFileSync(new URL("../../../i18n/locales/az.ts", import.meta.url), "utf8"),en: readFileSync(new URL("../../../i18n/locales/en.ts", import.meta.url), "utf8"),es: readFileSync(new URL("../../../i18n/locales/es.ts", import.meta.url), "utf8"),it: readFileSync(new URL("../../../i18n/locales/it.ts", import.meta.url), "utf8"),ja: readFileSync(new URL("../../../i18n/locales/ja.ts", import.meta.url), "utf8"),+ ko: readFileSync(new URL("../../../i18n/locales/ko.ts", import.meta.url), "utf8"),"pt-BR": readFileSync(new URL("../../../i18n/locales/pt-BR.ts", import.meta.url), "utf8"),+ tr: readFileSync(new URL("../../../i18n/locales/tr.ts", import.meta.url), "utf8"),"zh-CN": readFileSync(new URL("../../../i18n/locales/zh-CN.ts", import.meta.url), "utf8"),"zh-TW": readFileSync(new URL("../../../i18n/locales/zh-TW.ts", import.meta.url), "utf8"),};@@ -182,4 +185,55 @@ describe("Redis expiry mode wiring", () => {expect(deleted).toContain("removeKnownKey(keyRaw)");expect(loaded).toContain('if (value.redis_type === "none")');});++ it("reuses the shared expiry validator and the batch transport for one bulk policy", () => {+ const open = findFunction(browserSource, "openBatchExpiryDialog").getText();+ const save = findFunction(browserSource, "saveBatchExpiry").getText();+ const calls = callsIn(findFunction(browserSource, "saveBatchExpiry"));++ expect(open).toContain("if (checkedKeys.value.size === 0 || selectionBusy.value) return;");+ expect(open).toContain("batchExpiryKeyRaws.value = [...checkedKeys.value];");+ expect(save).toContain("validateRedisExpiry");+ expect(save).toContain("expiryValidationMessage(validation.reason)");+ expect(calls.map(callName)).toContain("applyRedisBatchExpiryPolicy");+ expect(calls.map(callName)).toContain("applyBatchExpiryMetadata");+ // The single-key API must never be looped over a multi-selection.+ expect(calls.map(callName)).not.toContain("api.redisSetTtl");+ expect(calls.map(callName)).not.toContain("api.redisSetExpireAt");+ expect(calls.map(callName)).not.toContain("applyRedisExpiryPolicy");+ expect(save).toContain("if (savingBatchExpiry.value || batchExpiryKeyRaws.value.length === 0) return;");+ expect(browserSource).toContain("setKeysTtl: api.redisSetKeysTtl");+ expect(browserSource).toContain("setKeysExpireAt: api.redisSetKeysExpireAt");+ // A batch mutation owns the selection like a batch delete does.+ expect(browserSource).toContain("const mutatingKeys = computed(() => deletingKeys.value || savingBatchExpiry.value);");+ expect(findFunction(browserSource, "retainCheckedKeys").getText()).toContain("loadedKeyRaws.has(keyRaw)");+ });++ it("updates the loaded TTL badge instead of rescanning every applied key", () => {+ const applyMetadata = findFunction(browserSource, "applyBatchExpiryMetadata").getText();+ const applyTtl = findFunction(browserSource, "applyKeyTtlMetadata").getText();++ expect(applyTtl).toContain("updateRedisKeyInfoMetadataByRaw(flatKeyByRaw, nextKeyInfo)");+ expect(applyTtl).toContain("recordKeyTtlObservedAt(nextKeyInfo)");+ expect(applyTtl).toContain("updateRedisKeyTreeLeafMetadata(treeIndex, nextKeyInfo)");+ expect(applyMetadata).toContain('policy.mode === "ttl" ? policy.ttl : -1');+ // EXPIREAT with a past timestamp deletes the key, so the row must not keep a stale TTL.+ expect(applyMetadata).toContain("onKeyDeleted(keyRaw)");+ // One reactive refresh per batch, not one per selected key.+ expect(applyMetadata.match(/noExpiryProjectionEpoch\.value\+\+/g) ?? []).toHaveLength(1);+ expect(applyMetadata.match(/keyMetadataEpoch\.value\+\+/g) ?? []).toHaveLength(1);+ expect(applyMetadata.match(/syncListTtlTimer\(\)/g) ?? []).toHaveLength(1);+ });++ it("ships the batch expiration copy in every supported locale", () => {+ for (const [locale, source] of Object.entries(localeSources)) {+ for (const key of ["batchExpiry:", "batchExpiryTitle:", "batchExpirySelected:", "batchExpiryApply:", "batchExpirySuccess:", "batchExpiryPartial:"]) {+ expect(source, `${locale} is missing redis.${key}`).toContain(` ${key}`);+ }+ }+ // The dialog must resolve its copy through i18n instead of hard-coded text.+ expect(browserSource).toContain('t("redis.batchExpiryTitle")');+ expect(browserSource).toContain('t("redis.batchExpirySelected", { count: batchExpiryKeyRaws.length })');+ expect(browserSource).toContain('t("redis.batchExpiryPartial", { success: summary.applied, failed: failed.size })');+ });});diff --git a/apps/desktop/src/lib/backend/__tests__/redisExpiryApi.spec.ts b/apps/desktop/src/lib/backend/__tests__/redisExpiryApi.spec.tsindex dd6d00aa1c..2bdc0de8c1 100644--- a/apps/desktop/src/lib/backend/__tests__/redisExpiryApi.spec.ts+++ b/apps/desktop/src/lib/backend/__tests__/redisExpiryApi.spec.ts@@ -52,6 +52,23 @@ describe("Redis expiry Tauri API", () => {ttl: -1,});});++ it("invokes the batch expiry commands with every selected key in one call", async () => {+ mocks.invoke.mockResolvedValue({ applied: 2, missing_key_raws: ["bWlzc2luZw=="] });+ const { redisSetKeysExpireAt, redisSetKeysTtl } = await import("@/lib/backend/tauri");++ const keyRaws = ["c2Vzc2lvbjpht", "c2Vzc2lvbjpi", "bWlzc2luZw=="];+ await expect(redisSetKeysTtl("redis-1", 2, keyRaws, 90)).resolves.toEqual({ applied: 2, missing_key_raws: ["bWlzc2luZw=="] });+ expect(mocks.invoke).toHaveBeenNthCalledWith(1, "redis_set_keys_ttl", { connectionId: "redis-1", db: 2, keyRaws, ttl: 90 });++ await redisSetKeysExpireAt("redis-1", 2, keyRaws, 1_735_689_600);+ expect(mocks.invoke).toHaveBeenNthCalledWith(2, "redis_set_keys_expire_at", {+ connectionId: "redis-1",+ db: 2,+ keyRaws,+ expireAt: 1_735_689_600,+ });+ });});describe("Redis expiry HTTP API", () => {@@ -96,4 +113,22 @@ describe("Redis expiry HTTP API", () => {body: { connectionId: "redis-1", db: 2, keyRaw: "c2Vzc2lvbg==", expireAt: 1_735_689_600 },});});++ it("posts one batch expiry request per bounded chunk of selected keys", async () => {+ const fetchMock = stubFetch();+ const { redisSetKeysExpireAt, redisSetKeysTtl } = await import("@/lib/backend/http");++ const keyRaws = ["c2Vzc2lvbjpht", "c2Vzc2lvbjpi"];+ await redisSetKeysTtl("redis-1", 2, keyRaws, -1);+ expect(lastCall(fetchMock)).toEqual({+ url: "/api/redis/set-keys-ttl",+ body: { connectionId: "redis-1", db: 2, keyRaws, ttl: -1 },+ });++ await redisSetKeysExpireAt("redis-1", 2, keyRaws, 1_735_689_600);+ expect(lastCall(fetchMock)).toEqual({+ url: "/api/redis/set-keys-expire-at",+ body: { connectionId: "redis-1", db: 2, keyRaws, expireAt: 1_735_689_600 },+ });+ });});diff --git a/apps/desktop/src/lib/backend/api.ts b/apps/desktop/src/lib/backend/api.tsindex 3111426bcf..603ef6e20a 100644--- a/apps/desktop/src/lib/backend/api.ts+++ b/apps/desktop/src/lib/backend/api.ts@@ -509,6 +509,8 @@ export const redisJsonSet = forward("redisJsonSet");export const redisCheckJsonModule = forward("redisCheckJsonModule");export const redisSetTtl = forward("redisSetTtl");export const redisSetExpireAt = forward("redisSetExpireAt");+export const redisSetKeysTtl = forward("redisSetKeysTtl");+export const redisSetKeysExpireAt = forward("redisSetKeysExpireAt");export const redisDeleteKeys = forward("redisDeleteKeys");export const redisFlushDb = forward("redisFlushDb");export const redisExecuteCommand = forward("redisExecuteCommand");@@ -900,6 +902,7 @@ export type {RedisDatabaseInfo,RedisHashItem,RedisKeyInfo,+ RedisKeysExpiryResult,RedisListItem,RedisSetItem,RedisStreamConsumer,diff --git a/apps/desktop/src/lib/backend/http.ts b/apps/desktop/src/lib/backend/http.tsindex ba5b0a0cff..19e6106596 100644--- a/apps/desktop/src/lib/backend/http.ts+++ b/apps/desktop/src/lib/backend/http.ts@@ -86,6 +86,7 @@ import type {RedisStreamPage,RedisStreamPendingPage,RedisValue,+ RedisKeysExpiryResult,RedisScanResult,RedisCommandResult,RedisSlowlogEntry,@@ -2955,6 +2956,14 @@ export async function redisSetExpireAt(connectionId: string, db: number, keyRaw:});}+export async function redisSetKeysTtl(connectionId: string, db: number, keyRaws: string[], ttl: number): Promise<RedisKeysExpiryResult> {+ return post("/api/redis/set-keys-ttl", { connectionId, db, keyRaws, ttl });+}++export async function redisSetKeysExpireAt(connectionId: string, db: number, keyRaws: string[], expireAt: number): Promise<RedisKeysExpiryResult> {+ return post("/api/redis/set-keys-expire-at", { connectionId, db, keyRaws, expireAt });+}+export async function redisDeleteKeys(connectionId: string, db: number, keyRaws: string[]): Promise<number> {return post("/api/redis/delete-keys", { connectionId, db, keyRaws });}diff --git a/apps/desktop/src/lib/backend/tauri.ts b/apps/desktop/src/lib/backend/tauri.tsindex 1eef2b9a28..7ac1be21ca 100644--- a/apps/desktop/src/lib/backend/tauri.ts+++ b/apps/desktop/src/lib/backend/tauri.ts@@ -2604,6 +2604,11 @@ export interface RedisZsetItem {member: RedisBlob;}+export interface RedisKeysExpiryResult {+ applied: number;+ missing_key_raws: string[];+}+export interface RedisStreamField {field: string;value: string;@@ -2892,6 +2897,14 @@ export async function redisSetExpireAt(connectionId: string, db: number, keyRaw:return invoke("redis_set_expire_at", { connectionId, db, keyRaw, expireAt });}+export async function redisSetKeysTtl(connectionId: string, db: number, keyRaws: string[], ttl: number): Promise<RedisKeysExpiryResult> {+ return invoke("redis_set_keys_ttl", { connectionId, db, keyRaws, ttl });+}++export async function redisSetKeysExpireAt(connectionId: string, db: number, keyRaws: string[], expireAt: number): Promise<RedisKeysExpiryResult> {+ return invoke("redis_set_keys_expire_at", { connectionId, db, keyRaws, expireAt });+}+export async function redisDeleteKeys(connectionId: string, db: number, keyRaws: string[]): Promise<number> {return invoke("redis_delete_keys", { connectionId, db, keyRaws });}diff --git a/apps/desktop/src/lib/redis/redisExpiry.spec.ts b/apps/desktop/src/lib/redis/redisExpiry.spec.tsindex 81d36deb53..efa4d82e4d 100644--- a/apps/desktop/src/lib/redis/redisExpiry.spec.ts+++ b/apps/desktop/src/lib/redis/redisExpiry.spec.ts@@ -1,7 +1,7 @@import { CalendarDateTime, resetLocalTimeZone, setLocalTimeZone } from "@internationalized/date";import { afterEach, describe, expect, it, vi } from "vitest";import { calendarDateTimeToUnixSeconds, formatLocalDateTime, parseLocalDateTime, unixSecondsToCalendarDateTime } from "@/components/ui/date-time-picker/dateTimePicker";-import { applyRedisExpiryPolicy, parseRedisTtl, redisExpiryModeForTtl, validateRedisExpiry } from "./redisExpiry";+import { applyRedisBatchExpiryPolicy, applyRedisExpiryPolicy, parseRedisTtl, redisExpiryModeForTtl, validateRedisExpiry } from "./redisExpiry";afterEach(() => {resetLocalTimeZone();@@ -71,3 +71,79 @@ describe("Redis expiry helpers", () => {expect(transport.setExpireAt).toHaveBeenCalledWith("connection", 3, "key", 1_735_689_600);});});++function batchTransport(results: { applied: number; missing_key_raws: string[] }[] = []) {+ const queue = [...results];+ const next = () => Promise.resolve(queue.shift() ?? { applied: 0, missing_key_raws: [] });+ return {+ setKeysTtl: vi.fn().mockImplementation(next),+ setKeysExpireAt: vi.fn().mockImplementation(next),+ };+}++describe("Redis batch expiry helpers", () => {+ it("applies one PERSIST for an empty policy, a TTL for a relative policy, and one EXPIREAT for an absolute policy", async () => {+ const none = batchTransport([{ applied: 1, missing_key_raws: [] }]);+ await applyRedisBatchExpiryPolicy(none, "connection", 3, ["key:a"], { mode: "none" });+ expect(none.setKeysTtl).toHaveBeenCalledWith("connection", 3, ["key:a"], -1);+ expect(none.setKeysExpireAt).not.toHaveBeenCalled();++ const ttl = batchTransport([{ applied: 2, missing_key_raws: [] }]);+ await applyRedisBatchExpiryPolicy(ttl, "connection", 3, ["key:a", "key:b"], { mode: "ttl", ttl: 3_600 });+ expect(ttl.setKeysTtl).toHaveBeenCalledWith("connection", 3, ["key:a", "key:b"], 3_600);+ expect(ttl.setKeysExpireAt).not.toHaveBeenCalled();++ const at = batchTransport([{ applied: 2, missing_key_raws: [] }]);+ await applyRedisBatchExpiryPolicy(at, "connection", 3, ["key:a", "key:b"], { mode: "at", expireAt: 1_735_689_600 });+ expect(at.setKeysExpireAt).toHaveBeenCalledWith("connection", 3, ["key:a", "key:b"], 1_735_689_600);+ expect(at.setKeysTtl).not.toHaveBeenCalled();+ });++ it("sums per-key results and reports the keys the server did not update", async () => {+ const transport = batchTransport([+ { applied: 1, missing_key_raws: ["key:b"] },+ { applied: 1, missing_key_raws: [] },+ ]);++ const summary = await applyRedisBatchExpiryPolicy(transport, "connection", 3, ["key:a", "key:b", "key:c"], { mode: "ttl", ttl: 60 }, 2);++ expect(transport.setKeysTtl).toHaveBeenCalledTimes(2);+ expect(transport.setKeysTtl).toHaveBeenNthCalledWith(1, "connection", 3, ["key:a", "key:b"], 60);+ expect(transport.setKeysTtl).toHaveBeenNthCalledWith(2, "connection", 3, ["key:c"], 60);+ expect(summary).toEqual({ applied: 2, failedKeyRaws: ["key:b"], errors: [] });+ });++ it("sends a large selection as bounded chunks instead of one request per key", async () => {+ const keyRaws = Array.from({ length: 2_501 }, (_, index) => `key:${index}`);+ const transport = batchTransport();++ const summary = await applyRedisBatchExpiryPolicy(transport, "connection", 3, keyRaws, { mode: "none" });++ expect(transport.setKeysTtl.mock.calls.map((call) => call[2].length)).toEqual([1_000, 1_000, 501]);+ expect(summary.failedKeyRaws).toEqual([]);+ });++ it("keeps the keys an earlier chunk already updated when a later chunk fails", async () => {+ const transport = batchTransport([{ applied: 2, missing_key_raws: [] }]);+ transport.setKeysTtl.mockImplementationOnce(() => Promise.resolve({ applied: 2, missing_key_raws: [] }));+ transport.setKeysTtl.mockImplementationOnce(() => Promise.reject(new Error("connection lost")));++ const summary = await applyRedisBatchExpiryPolicy(transport, "connection", 3, ["key:a", "key:b", "key:c"], { mode: "ttl", ttl: 60 }, 2);++ expect(summary.applied).toBe(2);+ expect(summary.failedKeyRaws).toEqual(["key:c"]);+ expect(summary.errors).toEqual(["connection lost"]);+ });++ it("deduplicates the selection and sends nothing for an empty one", async () => {+ const transport = batchTransport([{ applied: 1, missing_key_raws: [] }]);++ const empty = await applyRedisBatchExpiryPolicy(transport, "connection", 3, [], { mode: "none" });+ expect(empty).toEqual({ applied: 0, failedKeyRaws: [], errors: [] });+ expect(transport.setKeysTtl).not.toHaveBeenCalled();++ const summary = await applyRedisBatchExpiryPolicy(transport, "connection", 3, ["key:a", "key:a"], { mode: "none" });+ expect(transport.setKeysTtl).toHaveBeenCalledWith("connection", 3, ["key:a"], -1);+ expect(summary.applied).toBe(1);+ });+});diff --git a/apps/desktop/src/lib/redis/redisExpiry.ts b/apps/desktop/src/lib/redis/redisExpiry.tsindex a7d048435d..e00ccc1966 100644--- a/apps/desktop/src/lib/redis/redisExpiry.ts+++ b/apps/desktop/src/lib/redis/redisExpiry.ts@@ -1,5 +1,7 @@import type { CalendarDateTime } from "@internationalized/date";import { calendarDateTimeToUnixSeconds } from "@/components/ui/date-time-picker/dateTimePicker";+import type { RedisKeysExpiryResult } from "@/lib/backend/api";+import { REDIS_KEY_MUTATION_BATCH_SIZE, chunkRedisKeyRaws } from "@/lib/redis/redisKeyBatch";export type RedisExpiryMode = "none" | "ttl" | "at";@@ -12,6 +14,25 @@ export interface RedisExpiryTransport {setExpireAt: (connectionId: string, db: number, keyRaw: string, expireAt: number) => Promise<void>;}+/**+ * Batch counterpart of {@link RedisExpiryTransport}. One call covers a bounded+ * chunk of keys, so a large selection never becomes one request per key.+ */+export interface RedisBatchExpiryTransport {+ setKeysTtl: (connectionId: string, db: number, keyRaws: string[], ttl: number) => Promise<RedisKeysExpiryResult>;+ setKeysExpireAt: (connectionId: string, db: number, keyRaws: string[], expireAt: number) => Promise<RedisKeysExpiryResult>;+}++/** Per-key outcome of a batch expiration, aggregated across every chunk. */+export interface RedisBatchExpirySummary {+ /** Keys the server confirmed as updated. */+ applied: number;+ /** Keys that were not updated, so the caller can keep them selected for a retry. */+ failedKeyRaws: string[];+ /** Transport failures, one per chunk that never returned per-key results. */+ errors: string[];+}+/** Parse the EXPIRE argument without accepting partial, negative, or unsafe values. */export function parseRedisTtl(value: string): number | null {const trimmed = value.trim();@@ -55,3 +76,29 @@ export async function applyRedisExpiryPolicy(transport: RedisExpiryTransport, co}await transport.setExpireAt(connectionId, db, keyRaw, policy.expireAt);}++/**+ * Applies one validated policy to every selected key through the batch transport.+ *+ * Chunking keeps a 1000-key selection to a bounded number of requests, and a+ * chunk that fails outright keeps the keys an earlier chunk already updated+ * instead of discarding the whole result. Each chunk uses the same PERSIST /+ * EXPIRE / EXPIREAT shape as {@link applyRedisExpiryPolicy}.+ */+export async function applyRedisBatchExpiryPolicy(transport: RedisBatchExpiryTransport, connectionId: string, db: number, keyRaws: readonly string[], policy: RedisExpiryPolicy, batchSize = REDIS_KEY_MUTATION_BATCH_SIZE): Promise<RedisBatchExpirySummary> {+ const summary: RedisBatchExpirySummary = { applied: 0, failedKeyRaws: [], errors: [] };+ const uniqueKeyRaws = [...new Set(keyRaws)];+ if (uniqueKeyRaws.length === 0) return summary;++ for (const batch of chunkRedisKeyRaws(uniqueKeyRaws, batchSize)) {+ try {+ const result = policy.mode === "at" ? await transport.setKeysExpireAt(connectionId, db, batch, policy.expireAt) : await transport.setKeysTtl(connectionId, db, batch, policy.mode === "ttl" ? policy.ttl : -1);+ summary.applied += result.applied;+ summary.failedKeyRaws.push(...result.missing_key_raws);+ } catch (error) {+ summary.failedKeyRaws.push(...batch);+ summary.errors.push(error instanceof Error ? error.message : String(error));+ }+ }+ return summary;+}diff --git a/apps/desktop/src/lib/redis/redisKeyBatch.ts b/apps/desktop/src/lib/redis/redisKeyBatch.tsindex 170d208b12..0c988f50e4 100644--- a/apps/desktop/src/lib/redis/redisKeyBatch.ts+++ b/apps/desktop/src/lib/redis/redisKeyBatch.ts@@ -1,7 +1,7 @@import type { RedisKeyInfo } from "@/lib/backend/api";-// Keep desktop IPC and Redis command payloads bounded for large group deletes.-export const REDIS_DELETE_KEY_BATCH_SIZE = 1_000;+// Keep desktop IPC and Redis command payloads bounded for large key mutations.+export const REDIS_KEY_MUTATION_BATCH_SIZE = 1_000;export function collectUniqueRedisKeys(keys: RedisKeyInfo[], loadedKeyRaws: Set<string>): RedisKeyInfo[] {const uniqueKeys: RedisKeyInfo[] = [];@@ -15,7 +15,7 @@ export function collectUniqueRedisKeys(keys: RedisKeyInfo[], loadedKeyRaws: Set<return uniqueKeys;}-export function* chunkRedisKeyRaws(keyRaws: readonly string[], batchSize = REDIS_DELETE_KEY_BATCH_SIZE): Generator<string[]> {+export function* chunkRedisKeyRaws(keyRaws: readonly string[], batchSize = REDIS_KEY_MUTATION_BATCH_SIZE): Generator<string[]> {for (let start = 0; start < keyRaws.length; start += batchSize) {yield keyRaws.slice(start, start + batchSize);}diff --git a/crates/dbx-core/src/db/redis_driver.rs b/crates/dbx-core/src/db/redis_driver.rsindex 00c1d5ad2b..fc31cf162c 100644--- a/crates/dbx-core/src/db/redis_driver.rs+++ b/crates/dbx-core/src/db/redis_driver.rs@@ -71,6 +71,45 @@ pub struct RedisScanResult {pub total_keys: u64,}+/// The expiration shapes the Key Browser may apply to a batch of selected keys.+///+/// The variants mirror [`set_ttl`] and [`set_expire_at`] exactly, so a batch edit+/// and a single-key edit send the same Redis command for the same user choice.+#[derive(Debug, Clone, Copy, PartialEq, Eq)]+pub enum RedisKeysExpiry {+ Persist,+ Ttl(i64),+ At(i64),+}++impl RedisKeysExpiry {+ /// Keeps the single-key convention where a non-positive TTL means PERSIST.+ pub fn from_ttl(ttl: i64) -> Self {+ if ttl > 0 {+ Self::Ttl(ttl)+ } else {+ Self::Persist+ }+ }++ fn command(self) -> &'static str {+ match self {+ Self::Persist => "PERSIST",+ Self::Ttl(_) => "EXPIRE",+ Self::At(_) => "EXPIREAT",+ }+ }+}++/// Per-key outcome of a batch expiration so a partial failure stays reportable.+#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]+pub struct RedisKeysExpiryResult {+ /// Keys the server confirmed as updated.+ pub applied: u64,+ /// Selected keys that no longer exist, so the caller can offer a retry.+ pub missing_key_raws: Vec<String>,+}+#[derive(Debug, Clone, Serialize, Deserialize)]pub struct RedisValue {pub key_display: String,@@ -3662,6 +3701,69 @@ where}}+/// Applies one expiration command per selected key in a single bounded round trip.+///+/// Keys the caller already selected may disappear concurrently, so this reports+/// them instead of failing the whole batch. `PERSIST` stays idempotent: Redis+/// answers 0 both for a missing key and for a key that is already persistent.+pub async fn set_keys_expiry<C>(+ con: &mut C,+ keys: &[Vec<u8>],+ expiry: RedisKeysExpiry,+) -> Result<RedisKeysExpiryResult, String>+where+ C: ConnectionLike + Send + Sync + Unpin,+{+ if keys.is_empty() {+ return Ok(RedisKeysExpiryResult::default());+ }++ let mut pipeline = Pipeline::with_capacity(keys.len());+ for key in keys {+ match expiry {+ RedisKeysExpiry::Persist => {+ pipeline.cmd("PERSIST").arg(key.as_slice());+ }+ RedisKeysExpiry::Ttl(ttl) => {+ pipeline.cmd("EXPIRE").arg(key.as_slice()).arg(ttl);+ }+ RedisKeysExpiry::At(expire_at) => {+ pipeline.cmd("EXPIREAT").arg(key.as_slice()).arg(expire_at);+ }+ }+ }++ let replies: Vec<RedisRawValue> = pipeline.query_async(con).await.map_err(|error| error.to_string())?;+ summarize_keys_expiry(keys, expiry, &replies)+}++fn summarize_keys_expiry(+ keys: &[Vec<u8>],+ expiry: RedisKeysExpiry,+ replies: &[RedisRawValue],+) -> Result<RedisKeysExpiryResult, String> {+ let mut result = RedisKeysExpiryResult::default();+ for (index, key) in keys.iter().enumerate() {+ let applied = match expiry {+ // Redis answers 0 for an already-persistent key as well, so PERSIST+ // must not be reported as a missing key.+ RedisKeysExpiry::Persist => true,+ _ => match replies.get(index) {+ Some(RedisRawValue::Int(reply)) => *reply == 1,+ // A server error or a short reply must not be silently counted+ // as a per-key miss, or the batch would report a false success.+ _ => return Err(format!("{} did not return one reply per selected key", expiry.command())),+ },+ };+ if applied {+ result.applied += 1;+ } else {+ result.missing_key_raws.push(redis_key_bytes_to_raw(key));+ }+ }+ Ok(result)+}+pub async fn set_hash_field_ttl<C>(con: &mut C, key: &[u8], field: &str, ttl: i64) -> Result<(), String>whereC: ConnectionLike + Send + Sync + Unpin,@@ -5364,6 +5466,82 @@ mod tests {assert_eq!(con.command_count("EVAL"), 0);}+ #[tokio::test]+ async fn set_keys_expiry_expires_every_selected_key_in_one_pipeline() {+ let mut con =+ FakeRedisConnection::new(vec![RedisRawValue::Int(1), RedisRawValue::Int(1), RedisRawValue::Int(1)]);+ let keys = vec![b"key:a".to_vec(), b"key:b".to_vec(), b"key:c".to_vec()];++ let result = super::set_keys_expiry(&mut con, &keys, super::RedisKeysExpiry::Ttl(3_600)).await.unwrap();++ assert_eq!(result, super::RedisKeysExpiryResult { applied: 3, missing_key_raws: Vec::new() });+ // One pipeline for the whole selection, with one command per selected key.+ assert_eq!(con.commands.len(), 1);+ assert_eq!(con.commands[0].matches("\r\nEXPIRE\r\n").count(), 3);+ assert_eq!(con.commands[0].matches("\r\nEXPIREAT\r\n").count(), 0);+ assert_eq!(con.commands[0].matches("\r\nPERSIST\r\n").count(), 0);+ assert_eq!(con.commands[0].matches("\r\n3600\r\n").count(), 3);+ }++ #[tokio::test]+ async fn set_keys_expiry_reports_only_the_keys_that_disappeared() {+ let mut con =+ FakeRedisConnection::new(vec![RedisRawValue::Int(1), RedisRawValue::Int(0), RedisRawValue::Int(1)]);+ let keys = vec![b"key:a".to_vec(), b"key:b".to_vec(), b"key:c".to_vec()];++ let result = super::set_keys_expiry(&mut con, &keys, super::RedisKeysExpiry::At(1_735_689_600)).await.unwrap();++ assert_eq!(result.applied, 2);+ assert_eq!(result.missing_key_raws, vec![super::redis_key_bytes_to_raw(b"key:b")]);+ assert_eq!(con.commands[0].matches("\r\nEXPIREAT\r\n").count(), 3);+ assert!(con.commands[0].contains("\r\n1735689600\r\n"));+ }++ #[tokio::test]+ async fn set_keys_expiry_treats_persist_as_idempotent_for_every_key() {+ let mut con = FakeRedisConnection::new(vec![RedisRawValue::Int(0), RedisRawValue::Int(1)]);+ let keys = vec![b"key:a".to_vec(), b"key:b".to_vec()];++ let result = super::set_keys_expiry(&mut con, &keys, super::RedisKeysExpiry::from_ttl(-1)).await.unwrap();++ assert_eq!(result, super::RedisKeysExpiryResult { applied: 2, missing_key_raws: Vec::new() });+ assert_eq!(con.commands.len(), 1);+ assert_eq!(con.commands[0].matches("\r\nPERSIST\r\n").count(), 2);+ assert_eq!(con.commands[0].matches("\r\nEXPIRE\r\n").count(), 0);+ }++ #[tokio::test]+ async fn set_keys_expiry_keeps_ttl_zero_on_the_persist_path() {+ let mut con = FakeRedisConnection::new(vec![RedisRawValue::Int(1)]);++ let result =+ super::set_keys_expiry(&mut con, &[b"key:a".to_vec()], super::RedisKeysExpiry::from_ttl(0)).await.unwrap();++ assert_eq!(result.applied, 1);+ assert_eq!(con.command_count("PERSIST"), 1);+ }++ #[tokio::test]+ async fn set_keys_expiry_does_not_send_a_command_for_an_empty_selection() {+ let mut con = FakeRedisConnection::new(Vec::new());++ let result = super::set_keys_expiry(&mut con, &[], super::RedisKeysExpiry::Ttl(60)).await.unwrap();++ assert_eq!(result, super::RedisKeysExpiryResult::default());+ assert!(con.commands.is_empty());+ }++ #[tokio::test]+ async fn set_keys_expiry_fails_loudly_when_a_reply_is_missing() {+ let mut con = FakeRedisConnection::new(vec![RedisRawValue::Int(1)]);+ let keys = vec![b"key:a".to_vec(), b"key:b".to_vec()];++ let error = super::set_keys_expiry(&mut con, &keys, super::RedisKeysExpiry::Ttl(60)).await.unwrap_err();++ // A short or failed reply must not be reported as two successful keys.+ assert!(error.contains("EXPIRE did not return one reply per selected key"));+ }+#[tokio::test]async fn set_string_falls_back_to_pttl_and_px_when_keepttl_is_unsupported() {let unsupported = redis::RedisError::from((diff --git a/crates/dbx-core/src/redis_ops.rs b/crates/dbx-core/src/redis_ops.rsindex c4bb3e46ef..9582c74cd2 100644--- a/crates/dbx-core/src/redis_ops.rs+++ b/crates/dbx-core/src/redis_ops.rs@@ -1,7 +1,8 @@use crate::connection::{AppState, PoolKind};use crate::db::redis_driver::{- self, RedisCollectionPage, RedisCommandResult, RedisConnection, RedisDatabaseInfo, RedisScanResult,- RedisStreamConsumer, RedisStreamGroup, RedisStreamPage, RedisStreamPendingPage, RedisValue,+ self, RedisCollectionPage, RedisCommandResult, RedisConnection, RedisDatabaseInfo, RedisKeysExpiry,+ RedisKeysExpiryResult, RedisScanResult, RedisStreamConsumer, RedisStreamGroup, RedisStreamPage,+ RedisStreamPendingPage, RedisValue,};async fn ensure_redis_pool(state: &AppState, connection_id: &str) -> Result<(), String> {@@ -979,6 +980,67 @@ pub async fn redis_set_expire_at_in_db_core(}}+pub async fn redis_set_keys_ttl_in_db_core(+ state: &AppState,+ connection_id: &str,+ db: u32,+ key_raws: &[String],+ ttl: i64,+) -> Result<RedisKeysExpiryResult, String> {+ apply_redis_keys_expiry(state, connection_id, db, key_raws, RedisKeysExpiry::from_ttl(ttl)).await+}++pub async fn redis_set_keys_expire_at_in_db_core(+ state: &AppState,+ connection_id: &str,+ db: u32,+ key_raws: &[String],+ expire_at: i64,+) -> Result<RedisKeysExpiryResult, String> {+ apply_redis_keys_expiry(state, connection_id, db, key_raws, RedisKeysExpiry::At(expire_at)).await+}++/// Applies one expiration policy to every selected key, reporting per-key misses.+async fn apply_redis_keys_expiry(+ state: &AppState,+ connection_id: &str,+ db: u32,+ key_raws: &[String],+ expiry: RedisKeysExpiry,+) -> Result<RedisKeysExpiryResult, String> {+ ensure_redis_pool(state, connection_id).await?;+ let pool = state.pool_handle(connection_id).await.ok_or("Not found")?;+ match &pool {+ PoolKind::Redis(redis) => {+ let keys: Result<Vec<Vec<u8>>, String> =+ key_raws.iter().map(|key| redis_driver::redis_key_raw_to_bytes(key)).collect();+ let keys = keys?;+ match redis.as_ref() {+ RedisConnection::Direct(con) => {+ let mut con = con.lock().await;+ redis_driver::select_db(&mut *con, db).await?;+ redis_driver::set_keys_expiry(&mut *con, &keys, expiry).await+ }+ RedisConnection::Cluster(cluster) => {+ redis_driver::ensure_cluster_db(db)?;+ // A cluster pipeline cannot span slots, so every key keeps+ // its own slot-routed connection, like `redis_delete_keys`.+ let mut result = RedisKeysExpiryResult::default();+ for key in &keys {+ let mut con = redis_driver::cluster_key_connection(cluster, key).await?;+ let applied =+ redis_driver::set_keys_expiry(&mut con, std::slice::from_ref(key), expiry).await?;+ result.applied += applied.applied;+ result.missing_key_raws.extend(applied.missing_key_raws);+ }+ Ok(result)+ }+ }+ }+ _ => Err("Not a Redis connection".to_string()),+ }+}+pub async fn redis_delete_keys_in_db_core(state: &AppState,connection_id: &str,diff --git a/crates/dbx-core/tests/live_redis_batch_expiry.rs b/crates/dbx-core/tests/live_redis_batch_expiry.rsnew file mode 100644index 0000000000..2dc19193df--- /dev/null+++ b/crates/dbx-core/tests/live_redis_batch_expiry.rs@@ -0,0 +1,145 @@+use std::sync::Arc;+use std::time::{SystemTime, UNIX_EPOCH};++use dbx_core::connection::AppState;+use dbx_core::models::connection::{ConnectionConfig, DatabaseType};+use dbx_core::redis_ops::{+ redis_delete_keys_in_db_core, redis_get_ttl_in_db_core, redis_set_keys_expire_at_in_db_core,+ redis_set_keys_ttl_in_db_core, redis_set_string_in_db_core,+};+use dbx_core::storage::Storage;++/// Shared Redis fixtures used by the batch-expiration coverage below.+///+/// Run with a live server:+/// `DBX_LIVE_REDIS_HOST=... DBX_LIVE_REDIS_PORT=... DBX_LIVE_REDIS_PASSWORD=... \+/// cargo test -p dbx-core --test live_redis_batch_expiry -- --ignored --nocapture`+async fn live_state(connection_id: &str) -> Arc<AppState> {+ let host = std::env::var("DBX_LIVE_REDIS_HOST").expect("DBX_LIVE_REDIS_HOST");+ let port = std::env::var("DBX_LIVE_REDIS_PORT").expect("DBX_LIVE_REDIS_PORT").parse::<u16>().expect("Redis port");+ let username = std::env::var("DBX_LIVE_REDIS_USERNAME").unwrap_or_default();+ let password = std::env::var("DBX_LIVE_REDIS_PASSWORD").unwrap_or_default();+ let directory = tempfile::tempdir().unwrap();+ let storage = Storage::open(&directory.path().join("storage.db")).await.unwrap();+ let state = Arc::new(AppState::new(storage));+ let redis_config: ConnectionConfig = serde_json::from_value(serde_json::json!({+ "id": connection_id,+ "name": "Live batch expiry Redis",+ "db_type": DatabaseType::Redis,+ "host": host,+ "port": port,+ "username": username,+ "password": password,+ "database": null,+ "connect_timeout_secs": 5,+ "query_timeout_secs": 5,+ "idle_timeout_secs": 60,+ "keepalive_interval_secs": 0+ }))+ .unwrap();+ state.configs.write().await.insert(redis_config.id.clone(), redis_config.clone());+ state.get_or_create_pool(&redis_config.id, None).await.expect("open Redis connection");+ state+}++fn unique_prefix() -> String {+ let nanos = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos();+ format!("dbx_8899_{nanos}")+}++fn key_raws(prefix: &str) -> Vec<String> {+ // The browser always sends base64 key payloads, so the live test does too.+ (0..3)+ .map(|index| dbx_core::db::redis_driver::redis_key_bytes_to_raw(format!("{prefix}:{index}").as_bytes()))+ .collect()+}++async fn seed(state: &AppState, connection_id: &str, prefix: &str) -> Vec<String> {+ let raws = key_raws(prefix);+ for raw in &raws {+ redis_set_string_in_db_core(state, connection_id, 0, raw, "value", None).await.expect("seed Redis key");+ }+ raws+}++async fn ttls(state: &AppState, connection_id: &str, raws: &[String]) -> Vec<i64> {+ let mut values = Vec::new();+ for raw in raws {+ values.push(redis_get_ttl_in_db_core(state, connection_id, 0, raw).await.expect("read Redis TTL"));+ }+ values+}++async fn cleanup(state: &AppState, connection_id: &str, raws: &[String]) {+ let _ = redis_delete_keys_in_db_core(state, connection_id, 0, raws).await;+}++#[tokio::test]+#[ignore = "requires DBX_LIVE_REDIS_HOST and DBX_LIVE_REDIS_PORT"]+async fn set_keys_ttl_expires_every_selected_key_on_a_live_server() {+ let connection_id = "live-redis-batch-ttl";+ let state = live_state(connection_id).await;+ let prefix = unique_prefix();+ let raws = seed(&state, connection_id, &prefix).await;++ let result = redis_set_keys_ttl_in_db_core(&state, connection_id, 0, &raws, 3_600).await.expect("apply batch TTL");+ assert_eq!(result.applied, 3);+ assert!(result.missing_key_raws.is_empty(), "unexpected misses: {:?}", result.missing_key_raws);++ for ttl in ttls(&state, connection_id, &raws).await {+ assert!((3_590..=3_600).contains(&ttl), "unexpected TTL {ttl}");+ }++ // A non-positive TTL keeps the single-key PERSIST convention.+ let persisted = redis_set_keys_ttl_in_db_core(&state, connection_id, 0, &raws, -1).await.expect("persist keys");+ assert_eq!(persisted.applied, 3);+ assert_eq!(ttls(&state, connection_id, &raws).await, vec![-1, -1, -1]);++ cleanup(&state, connection_id, &raws).await;+}++#[tokio::test]+#[ignore = "requires DBX_LIVE_REDIS_HOST and DBX_LIVE_REDIS_PORT"]+async fn set_keys_expire_at_uses_one_absolute_deadline_on_a_live_server() {+ let connection_id = "live-redis-batch-expireat";+ let state = live_state(connection_id).await;+ let prefix = unique_prefix();+ let raws = seed(&state, connection_id, &prefix).await;++ let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() as i64;+ let expire_at = now + 7_200;+ let result = redis_set_keys_expire_at_in_db_core(&state, connection_id, 0, &raws, expire_at)+ .await+ .expect("apply batch EXPIREAT");+ assert_eq!(result.applied, 3);++ for ttl in ttls(&state, connection_id, &raws).await {+ // Every key shares the same deadline, minus the seconds the round trip took.+ assert!((7_190..=7_200).contains(&ttl), "unexpected absolute TTL {ttl}");+ }++ cleanup(&state, connection_id, &raws).await;+}++#[tokio::test]+#[ignore = "requires DBX_LIVE_REDIS_HOST and DBX_LIVE_REDIS_PORT"]+async fn set_keys_ttl_reports_a_concurrently_deleted_key_without_failing_the_batch() {+ let connection_id = "live-redis-batch-partial";+ let state = live_state(connection_id).await;+ let prefix = unique_prefix();+ let mut raws = seed(&state, connection_id, &prefix).await;+ raws.push(dbx_core::db::redis_driver::redis_key_bytes_to_raw(format!("{prefix}:deleted").as_bytes()));++ let result =+ redis_set_keys_ttl_in_db_core(&state, connection_id, 0, &raws, 600).await.expect("apply partial batch TTL");++ assert_eq!(result.applied, 3);+ assert_eq!(result.missing_key_raws.len(), 1);+ assert_eq!(result.missing_key_raws[0], raws[3]);+ // The keys that did exist were still expired by the same request.+ for ttl in ttls(&state, connection_id, &raws[..3]).await {+ assert!((590..=600).contains(&ttl), "unexpected TTL {ttl}");+ }++ cleanup(&state, connection_id, &raws).await;+}diff --git a/crates/dbx-web/src/main.rs b/crates/dbx-web/src/main.rsindex ff1440490b..7d897cf071 100644--- a/crates/dbx-web/src/main.rs+++ b/crates/dbx-web/src/main.rs@@ -662,6 +662,8 @@ async fn main() {.route("/redis/check-json-module", post(routes::redis::check_json_module)).route("/redis/set-ttl", post(routes::redis::set_ttl)).route("/redis/set-expire-at", post(routes::redis::set_expire_at))+ .route("/redis/set-keys-ttl", post(routes::redis::set_keys_ttl))+ .route("/redis/set-keys-expire-at", post(routes::redis::set_keys_expire_at)).route("/redis/delete-keys", post(routes::redis::delete_keys)).route("/redis/flush-db", post(routes::redis::flush_db)).route("/redis/execute-command", post(routes::redis::execute_command))diff --git a/crates/dbx-web/src/routes/redis.rs b/crates/dbx-web/src/routes/redis.rsindex e4ae92eab8..71c0b715ae 100644--- a/crates/dbx-web/src/routes/redis.rs+++ b/crates/dbx-web/src/routes/redis.rs@@ -7,6 +7,7 @@ use serde::Deserialize;use crate::error::AppError;use crate::state::WebState;+use dbx_core::db::redis_driver::RedisKeysExpiryResult;/// Check if a connection is read-only and return an error if so.async fn ensure_writable(@@ -262,6 +263,24 @@ pub struct RedisSetExpireAtRequest {pub expire_at: i64,}+#[derive(Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct RedisKeysTtlRequest {+ pub connection_id: String,+ pub db: u32,+ pub key_raws: Vec<String>,+ pub ttl: i64,+}++#[derive(Deserialize)]+#[serde(rename_all = "camelCase")]+pub struct RedisKeysExpireAtRequest {+ pub connection_id: String,+ pub db: u32,+ pub key_raws: Vec<String>,+ pub expire_at: i64,+}+#[derive(Deserialize)]#[serde(rename_all = "camelCase")]pub struct RedisKeysRequest {@@ -791,6 +810,40 @@ pub async fn set_expire_at(Ok(Json(()))}+pub async fn set_keys_ttl(+ State(state): State<Arc<WebState>>,+ Json(req): Json<RedisKeysTtlRequest>,+) -> Result<Json<RedisKeysExpiryResult>, AppError> {+ ensure_writable(&state.app, &req.connection_id, "EXPIRE").await?;+ let result = dbx_core::redis_ops::redis_set_keys_ttl_in_db_core(+ &state.app,+ &req.connection_id,+ req.db,+ &req.key_raws,+ req.ttl,+ )+ .await+ .map_err(AppError::from)?;+ Ok(Json(result))+}++pub async fn set_keys_expire_at(+ State(state): State<Arc<WebState>>,+ Json(req): Json<RedisKeysExpireAtRequest>,+) -> Result<Json<RedisKeysExpiryResult>, AppError> {+ ensure_writable(&state.app, &req.connection_id, "EXPIREAT").await?;+ let result = dbx_core::redis_ops::redis_set_keys_expire_at_in_db_core(+ &state.app,+ &req.connection_id,+ req.db,+ &req.key_raws,+ req.expire_at,+ )+ .await+ .map_err(AppError::from)?;+ Ok(Json(result))+}+pub async fn delete_keys(State(state): State<Arc<WebState>>,Json(req): Json<RedisKeysRequest>,diff --git a/docs/content/docs/redis.cn.mdx b/docs/content/docs/redis.cn.mdxindex 16eedfb3b6..b16f0c8b07 100644--- a/docs/content/docs/redis.cn.mdx+++ b/docs/content/docs/redis.cn.mdx@@ -109,6 +109,7 @@ Key 统计和 Slowlog 会额外调用 Redis 命令。大型实例或集群中应- 删除选中的 Key- 删除当前分组中已加载的 Key+- 为选中的 Key 批量设置 TTL、本地绝对过期时间或永不过期- 清空当前 Redis DB- 对支持的结构执行批量字段/成员操作diff --git a/docs/content/docs/redis.mdx b/docs/content/docs/redis.mdxindex 40e16c6949..fa3db6710c 100644--- a/docs/content/docs/redis.mdx+++ b/docs/content/docs/redis.mdx@@ -109,6 +109,7 @@ Key statistics and Slowlog require additional Redis commands. Limit scope and en- Delete selected keys- Delete keys loaded under the current group+- Set a relative TTL, a local absolute expiration time, or no expiry on selected keys- Flush the active Redis database- Run supported bulk field/member operationsdiff --git a/docs/content/docs/redis.tr.mdx b/docs/content/docs/redis.tr.mdxindex 0f8e4b9752..651934374e 100644--- a/docs/content/docs/redis.tr.mdx+++ b/docs/content/docs/redis.tr.mdx@@ -109,6 +109,7 @@ Anahtar istatistikleri ve Slowlog ek Redis komutları gerektirir. Büyük örnek- Seçili anahtarları silme- Geçerli grup altında yüklenmiş anahtarları silme+- Seçili anahtarlara göreli TTL, yerel mutlak son kullanma zamanı veya süresiz kayıt uygulama- Etkin Redis veritabanını temizleme- Desteklenen toplu alan/üye işlemlerini çalıştırmadiff --git a/packages/app-tests/redisKeyBatch.test.ts b/packages/app-tests/redisKeyBatch.test.tsindex eed356c64e..3e09e4220f 100644--- a/packages/app-tests/redisKeyBatch.test.ts+++ b/packages/app-tests/redisKeyBatch.test.ts@@ -1,6 +1,6 @@import { test } from "vitest";import assert from "node:assert/strict";-import { chunkRedisKeyRaws, collectUniqueRedisKeys, REDIS_DELETE_KEY_BATCH_SIZE } from "../../apps/desktop/src/lib/redis/redisKeyBatch.ts";+import { chunkRedisKeyRaws, collectUniqueRedisKeys, REDIS_KEY_MUTATION_BATCH_SIZE } from "../../apps/desktop/src/lib/redis/redisKeyBatch.ts";import type { RedisKeyInfo } from "../../apps/desktop/src/lib/backend/api.ts";function makeKey(key: string): RedisKeyInfo {@@ -41,13 +41,23 @@ test("collectUniqueRedisKeys handles large batches without changing key objects"assert.equal(keys.at(-1), input.at(-1));});-test("chunkRedisKeyRaws bounds large delete payloads without changing key order", () => {- const keyRaws = Array.from({ length: REDIS_DELETE_KEY_BATCH_SIZE * 2 + 1 }, (_, index) => `key:${index}`);+test("chunkRedisKeyRaws bounds large key mutation payloads without changing key order", () => {+ const keyRaws = Array.from({ length: REDIS_KEY_MUTATION_BATCH_SIZE * 2 + 1 }, (_, index) => `key:${index}`);const batches = [...chunkRedisKeyRaws(keyRaws)];assert.deepEqual(batches.map((batch) => batch.length),- [REDIS_DELETE_KEY_BATCH_SIZE, REDIS_DELETE_KEY_BATCH_SIZE, 1],+ [REDIS_KEY_MUTATION_BATCH_SIZE, REDIS_KEY_MUTATION_BATCH_SIZE, 1],);assert.deepEqual(batches.flat(), keyRaws);});++test("chunkRedisKeyRaws keeps one shared bound for delete and batch expiry payloads", () => {+ // Deletes and batch expirations must not drift into two different limits.+ const batches = [...chunkRedisKeyRaws(Array.from({ length: 2_500 }, (_, index) => `key:${index}`))];++ assert.deepEqual(+ batches.map((batch) => batch.length),+ [1_000, 1_000, 500],+ );+});diff --git a/src-tauri/src/commands/redis_cmd.rs b/src-tauri/src/commands/redis_cmd.rsindex 2fc1563c59..4e8cfd78f7 100644--- a/src-tauri/src/commands/redis_cmd.rs+++ b/src-tauri/src/commands/redis_cmd.rs@@ -4,8 +4,8 @@ use tauri::State;use crate::commands::connection::{ensure_connection_writable, AppState};use dbx_core::db::redis_driver::{classify_command, parse_command_argv, RedisCollectionPage, RedisCommandResult, RedisCommandSafety,- RedisDatabaseInfo, RedisScanResult, RedisStreamConsumer, RedisStreamGroup, RedisStreamPage, RedisStreamPendingPage,- RedisValue,+ RedisDatabaseInfo, RedisKeysExpiryResult, RedisScanResult, RedisStreamConsumer, RedisStreamGroup, RedisStreamPage,+ RedisStreamPendingPage, RedisValue,};#[tauri::command]@@ -444,6 +444,30 @@ pub async fn redis_set_expire_at(dbx_core::redis_ops::redis_set_expire_at_in_db_core(&state, &connection_id, db, &key_raw, expire_at).await}+#[tauri::command]+pub async fn redis_set_keys_ttl(+ state: State<'_, Arc<AppState>>,+ connection_id: String,+ db: u32,+ key_raws: Vec<String>,+ ttl: i64,+) -> Result<RedisKeysExpiryResult, String> {+ ensure_connection_writable(&state, &connection_id, "EXPIRE").await?;+ dbx_core::redis_ops::redis_set_keys_ttl_in_db_core(&state, &connection_id, db, &key_raws, ttl).await+}++#[tauri::command]+pub async fn redis_set_keys_expire_at(+ state: State<'_, Arc<AppState>>,+ connection_id: String,+ db: u32,+ key_raws: Vec<String>,+ expire_at: i64,+) -> Result<RedisKeysExpiryResult, String> {+ ensure_connection_writable(&state, &connection_id, "EXPIREAT").await?;+ dbx_core::redis_ops::redis_set_keys_expire_at_in_db_core(&state, &connection_id, db, &key_raws, expire_at).await+}+#[tauri::command]pub async fn redis_delete_keys(state: State<'_, Arc<AppState>>,diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex dbf59c791b..9c4fcdf999 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -2012,6 +2012,8 @@ pub fn run() {commands::redis_cmd::redis_check_json_module,commands::redis_cmd::redis_set_ttl,commands::redis_cmd::redis_set_expire_at,+ commands::redis_cmd::redis_set_keys_ttl,+ commands::redis_cmd::redis_set_keys_expire_at,commands::redis_cmd::redis_delete_keys,commands::redis_cmd::redis_flush_db,commands::redis_cmd::redis_execute_command,