Permanently destroying data

Should you choose to destroy cached and persisted data, the flush_all operation is available at the SDK level.

Warning: This operation is disabled by default as of the 1.8.1 Couchbase Server and above. This is to prevent accidental, detrimental data loss. Use of this operation should be done only with extreme caution, and most likely only for test databases as it will delete, item by item, every persisted document as well as destroy all cached data.
Warning:

Third-party client testing tools may perform a flush_all operation as part of their test scripts. Be aware of the scripts run by your testing tools and avoid triggering these test cases/operations unless you are certain they are being performed on your sample/test database.

Inadvertent use of flush_all on production databases, or other data stores you intend to use will result in permanent loss of data. Moreover the operation as applied to a large data store will take many hours to remove persisted documents.

This next example demonstrates how to perform a synchronous and asynchronous flush in Ruby:

#synchronous flush

c.flush    #=> true

#asynchronous flush

c.run do
    c.flush do |ret|
        ret.operation   #=> :flush
        ret.success?    #=> true
    ret.node        #=> "localhost:11211"
    end
end

In the case of asynchronous operations we use the event loop in Ruby. Within the loop we try to perform a flush.

When you perform a flush you provide the URI for one node in the cluster as a parameter and it will operate against all nodes in a cluster.