fix(redis): batch sparse key searches

This commit is contained in:
t8y2 committed 2026-07-02 18:41:25 +08:00
1 parent 44c91ae47d
commit d35c966390
2 files changed
+89 -2

No files matched your search

@@ -211,7 +211,12 @@ function mergeTree(newKeys: RedisKeyInfo[]) {
async function fetchScanPage(): Promise<RedisScanResult> {
const pageSize = redisScanPageSize.value;
return isValueSearchMode.value ? await api.redisScanValues(props.connectionId, props.db, scanCursor.value, "*", valueQuery.value, pageSize, searchMode.value === "all") : await api.redisScanKeysBatch(props.connectionId, props.db, scanCursor.value, effectivePattern.value, pageSize, 1, false);
// Redis SCAN may return an empty page with a non-zero cursor; batch a few
// key-search pages so sparse MATCH patterns do not look empty immediately.
const keySearchIterations = 8;
return isValueSearchMode.value
? await api.redisScanValues(props.connectionId, props.db, scanCursor.value, "*", valueQuery.value, pageSize, searchMode.value === "all")
: await api.redisScanKeysBatch(props.connectionId, props.db, scanCursor.value, effectivePattern.value, pageSize, keySearchIterations, false);
}
/// Batch-scan variant that performs multiple SCAN iterations server-side.