- Redis Basics
- Redis - Home
- Redis - Overview
- Redis - Environment
- Redis - Configuration
- Redis - Data types
- Redis Commands
- Redis - Commands
- Redis - Keys
- Redis - Strings
- Redis - Hashes
- Redis - Lists
- Redis - Sets
- Redis - Sorted Sets
- Redis - HyperLogLog
- Redis - Publish Subscribe
- Redis - Transactions
- Redis - Scripting
- Redis - Connections
- Redis - Server
- Redis Advanced
- Redis - Backup
- Redis - Security
- Redis - Benchmarks
- Redis - Client Connection
- Redis - Pipelining
- Redis - Partitioning
- Redis - Java
- Redis - Php
- Redis Useful Resources
- Redis - Quick Guide
- Redis - Useful Resources
- Redis - Discussion
Redis - Keys Command
Redis KEYS command is used to search keys with a matching pattern.
Return Value
List of keys with a matching pattern (Array).
Syntax
Following is the basic syntax of Redis KEYS command.
redis 127.0.0.1:6379> KEYS PATTERN
Example
First, create a key in Redis and set some value in it.
redis 127.0.0.1:6379> SET tutorial1 redis OK redis 127.0.0.1:6379> SET tutorial2 mysql OK redis 127.0.0.1:6379> SET tutorial3 mongodb OK
Now, search Redis with keys starting from the keyword tutorial.
redis 127.0.0.1:6379> KEYS tutorial* 1) "tutorial3" 2) "tutorial1" 3) "tutorial2"
To get a list of all the keys available in Redis, use only *
redis 127.0.0.1:6379> KEYS * 1) "tutorial3" 2) "tutorial1" 3) "tutorial2"
redis_keys.htm
Advertisements