Redis command to get all available keys?

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

    -->Get all keys from redis-cli

    -redis 127.0.0.1:6379> keys *
    

    -->Get list of patterns

    -redis 127.0.0.1:6379> keys d??
    

    This will produce keys which start by 'd' with three characters.

    -redis 127.0.0.1:6379> keys *t*
    

    This wil get keys with matches 't' character in key

    -->Count keys from command line by

    -redis-cli keys * |wc -l
    

    -->Or you can use dbsize

    -redis-cli dbsize
    

提交回复
热议问题