How do I delete everything in Redis?

前端 未结 22 1053
无人共我
无人共我 2020-11-28 17:18

I want to delete all keys. I want everything wiped out and give me a blank database.

Is there a way to do this in Redis client?

22条回答
  •  悲&欢浪女
    2020-11-28 17:37

    If you are using Java then from the documentation, you can use any one of them based on your use case.

    /**
     * Remove all keys from all databases.
     *
     * @return String simple-string-reply
     */
    String flushall();
    
    /**
     * Remove all keys asynchronously from all databases.
     *
     * @return String simple-string-reply
     */
    String flushallAsync();
    
    /**
     * Remove all keys from the current database.
     *
     * @return String simple-string-reply
     */
    String flushdb();
    
    /**
     * Remove all keys asynchronously from the current database.
     *
     * @return String simple-string-reply
     */
    String flushdbAsync();
    

    Code:

    RedisAdvancedClusterCommands syncCommands = // get sync() or async() commands 
    syncCommands.flushdb();
    

    Read more: https://github.com/lettuce-io/lettuce-core/wiki/Redis-Cluster

提交回复
热议问题