Redis command to get all available keys?

后端 未结 15 2681
攒了一身酷
攒了一身酷 2020-12-04 04:30

Is there a Redis command for fetching all keys in the database? I have seen some python-redis libraries fetching them. But was wondering if it is possible from redis-client.

15条回答
  •  醉话见心
    2020-12-04 05:02

    It can happen that using redis-cli, you connect to your remote redis-server, and then the command:

    KEYS *
    

    is not showing anything, or better, it shows:
    (empty list or set)

    If you are absolutely sure that the Redis server you use is the one you have the data, then maybe your redis-cli is not connecting to the Redis correct database instance.

    As it is mentioned in the Redis docs, new connections connect as default to the db 0.

    In my case KEYS command was not retrieving results because my database was 1. In order to select the db you want, use SELECT.
    The db is identified by an integer.

    SELECT 1
    KEYS *
    

    I post this info because none of the previous answers was solving my issue.

提交回复
热议问题