How to Use DBX's Redis Browser for Key Pattern Search

DBX's Redis browser performs SCAN-based pattern matching through the redisKeySearchPattern() function, allowing you to locate keys using glob patterns with optional fuzzy matching directly from the desktop interface.

The DBX desktop application (t8y2/dbx) provides a visual Redis browser that simplifies key exploration without requiring CLI commands. Understanding how to leverage pattern search capabilities helps you efficiently navigate large keyspaces in Redis databases. This guide explains the implementation details and usage patterns for the DBX Redis browser key pattern search functionality based on the source code.

How Pattern Matching Works in DBX

The search logic centers on redisKeySearchPattern() in [apps/desktop/src/lib/redis/redisKeyPattern.ts](https://github.com/t8y2/dbx/blob/main/apps/desktop/src/lib/redis/redisKeyPattern.ts). This function prepares user input for Redis's SCAN MATCH operation.

Pattern Processing Logic

The function handles three core scenarios:

  • Empty input returns "*" to match all keys
  • Exact mode passes the pattern unchanged to Redis
  • Fuzzy mode wraps the input with wildcards and escapes special characters
// redisKeyPattern.ts
export function redisKeySearchPattern(value: string, fuzzy: boolean): string {
  const pattern = value.trim();
  if (!pattern) return "*";                     // empty input → match everything
  return fuzzy ? `*${escapeRedisGlobText(pattern, fuzzy)}*` : pattern;
}

The escapeRedisGlobText() helper prevents unintended interpretation of Redis glob characters (* ? [ ]) by escaping them when fuzzy mode is active.

Using the Redis Browser UI

The [RedisKeyBrowser.vue](https://github.com/t8y2/dbx/blob/main/apps/desktop/src/components/redis/RedisKeyBrowser.vue) component provides the search interface that orchestrates pattern-based key discovery.

Step-by-Step Search Workflow

  1. Enter a pattern (e.g., user:*) in the search input bound to the searchPattern reactive variable (lines 73-78)

  2. A 400ms debounce timer triggers loadKeys() (lines 447-452), resetting the key list and initiating the SCAN request

  3. The component computes an effectivePattern using the search mode and fuzzy toggle:

// RedisKeyBrowser.vue
const effectivePattern = computed(() =>
  (searchMode.value === "key"
    ? redisKeySearchPattern(searchPattern.value, fuzzyKeySearch.value)
    : "*"));
  1. The UI calls api.redisScanKeysBatch(), which invokes the Tauri command redis_scan_keys_batch in [src-tauri/src/commands/redis_cmd.rs](https://github.com/t8y2/dbx/blob/main/src-tauri/src/commands/redis_cmd.rs)

  2. The backend executes dbx_core::redis_ops::redis_scan_keys_batch_core from [crates/dbx-core/src/redis_ops.rs](https://github.com/t8y2/dbx/blob/main/crates/dbx-core/src/redis_ops.rs), performing the actual Redis SCAN MATCH <pattern> operation

  3. Results populate a virtual scroller for efficient browsing of large result sets

Search Modes and Pattern Syntax

DBX supports two distinct search behaviors controlled by the Fuzzy Match toggle button (<Button … @click="toggleFuzzyKeySearch">).

Exact Pattern Matching

When fuzzy mode is disabled, DBX transmits your input directly to Redis. This preserves standard Redis glob syntax:

  • * matches any character sequence
  • ? matches single characters
  • [aeiou] matches character classes

Use exact mode when you know the precise key structure or want to leverage advanced glob patterns.

Fuzzy Fragment Matching

Enabling fuzzy mode automatically adds leading and trailing * wildcards while escaping existing glob characters. This transforms a search for foo into *foo*, safely matching any key containing that substring regardless of surrounding text.

This mode is ideal when you remember only part of a key name or want to avoid constructing complex glob patterns manually.

Programmatic Pattern Examples

You can leverage the same pattern generation logic in custom scripts or tests:

// Search for keys with specific prefix
searchPattern.value = "session:*";
// Triggers loadKeys() automatically via UI binding
// Enable fuzzy matching for substring search
fuzzyKeySearch.value = true;
// Converts "order" to "*order*" internally
// Manual pattern generation for testing
import { redisKeySearchPattern } from "@/lib/redis/redisKeyPattern";

const pattern = redisKeySearchPattern("user_profile", true);
// Result: "*user_profile*"
// Direct API invocation for custom implementations
await api.redisScanKeysBatch(
  connectionId,
  dbNumber,
  0,                     // cursor: start at 0 for fresh scan
  "*session*",           // pattern generated via redisKeySearchPattern()
  pageSize,
  iterations,
  false                  // includeTypes: false
);

Performance Optimization

The DBX Redis browser implements several strategies to handle large keyspaces efficiently.

Pagination and Batch Sizes

The default redis_scan_page_size is set to 1,000 keys per SCAN iteration, defined in redisKeyPattern.ts. This balances retrieval speed with memory usage for the UI virtual scroller.

Fetch All Keys Mode

For complete keyspace enumeration, click "Fetch All Keys" which utilizes FETCH_ALL_SCAN_COUNT in RedisKeyBrowser.vue. This mode batches multiple SCAN iterations before rebuilding the tree view once, significantly reducing UI latency compared to incremental updates.

Summary

  • DBX Redis browser key pattern search uses redisKeySearchPattern() in redisKeyPattern.ts to prepare SCAN queries
  • The UI applies a 400ms debounce to loadKeys() calls for responsive typing without excessive database load
  • Exact mode preserves Redis glob syntax (*, ?, []) while fuzzy mode wraps inputs with * and escapes special characters
  • Backend SCAN operations execute through redis_scan_keys_batch in the Tauri Rust layer
  • Configure redis_scan_page_size (default 1,000) or use Fetch All Keys for large keyspace navigation

Frequently Asked Questions

What is the default SCAN page size in DBX?

The default page size is 1,000 keys per iteration, defined as redis_scan_page_size in apps/desktop/src/lib/redis/redisKeyPattern.ts. You can adjust this constant to trade between retrieval speed and memory consumption for large databases.

How does fuzzy matching differ from exact pattern search in the Redis browser?

Exact mode sends your input directly to Redis's SCAN MATCH command, interpreting * and ? as wildcards. Fuzzy mode automatically wraps your search term with * wildcards and escapes existing glob characters, performing a substring search without requiring manual pattern construction.

Where does the actual Redis SCAN command execute in the DBX architecture?

The frontend Vue component calls api.redisScanKeysBatch(), which invokes the Tauri command redis_scan_keys_batch in src-tauri/src/commands/redis_cmd.rs. This calls dbx_core::redis_ops::redis_scan_keys_batch_core in crates/dbx-core/src/redis_ops.rs to execute the native Redis SCAN operation.

Can I search for all keys without entering a pattern?

Yes. Leaving the search input empty triggers redisKeySearchPattern() to return "*", which matches all keys in the selected database. This is equivalent to using KEYS * in the Redis CLI, though DBX uses the safer SCAN cursor-based iteration to avoid blocking the server.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →