Redis command to get all available keys?

后端 未结 15 2662
攒了一身酷
攒了一身酷 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:13

    Try to look at KEYS command. KEYS * will list all keys stored in redis.

    EDIT: please note the warning at the top of KEYS documentation page:

    Time complexity: O(N) with N being the number of keys in the database, under the assumption that the key names in the database and the given pattern have limited length.

    UPDATE (V2.8 or greater): SCAN is a superior alternative to KEYS, in the sense that it does not block the server nor does it consume significant resources. Prefer using it.

提交回复
热议问题