Description
Returns all keys matching a glob-style pattern. This command should be used with caution in production environments as it can impact performance on large databases.Method Signature
Parameters
The glob-style pattern to match keys against. Supported glob patterns:
*matches any number of characters (including zero)?matches exactly one character[abc]matches one character from the set[^abc]matches one character not in the set[a-z]matches one character from the range\escapes special characters
Return Value
Array of keys matching the pattern. Returns an empty array if no keys match.
Examples
Match all keys
Match with prefix
Match with wildcard in middle
Match single character
Match character range
No matches
Performance Considerations
KEYS is a blocking operation that scans the entire keyspace. For production use:
- Use
SCANfor incremental iteration - Avoid using
KEYSon large databases - Consider using key naming schemes that allow targeted queries