barch

KEYS

Syntax

KEYS pattern [COUNT count the keys matching instead of returning them] | [MAX integer to limit results]

Complexity O(n)

Returns all keys matching pattern in an array.

While the time complexity for this operation is O(N), the constant times are fairly low. For example, BARCH running on an older laptop can scan a 1 million key database in 5 milliseconds (as opposed to the valkey hash table that blocks and takes 20 ms).

Note: Unlike valkey this command will not block any other access to the database, it will run in it’s own thread. However, each reply does take some memory so care should be taken to not choose a pattern to return to many results. The COUNT argument can be added to return only a count

Options

Supported glob-style patterns: