Memcached flush_all El comando se utiliza para eliminar todos los datos (pares clave-valor) del servidor Memcached. Toma un parámetro opcional llamado hora que establece el tiempo después del cual se deben borrar los datos de Memcached.
Sintaxis básica de Memcached flush_all comando como se muestra a continuación –
flush_all [time] [noreply]
El comando anterior siempre devuelve OK.
En el siguiente ejemplo, guardamos algunos datos en el servidor Memcached y luego borramos todos los datos.
set AreaTutorial 0 900 9 memcached STORED get AreaTutorial VALUE AreaTutorial 0 9 memcached END flush_all OK get AreaTutorial END
Para eliminar datos del servidor Memcached, debe usar Memcached rubor método.
import net.spy.memcached.MemcachedClient; public class MemcachedJava { public static void main(String[] args) { // Connecting to Memcached server on localhost MemcachedClient mcc = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211)); System.out.println("Connection to server sucessfully"); System.out.println("set status:"+mcc.set("count", 900, "5").isDone()); // Get value from cache System.out.println("Get from Cache:"+mcc.get("count")); // now increase the stored value System.out.println("Increment value:"+mcc.incr("count", 2)); // now decrease the stored value System.out.println("Decrement value:"+mcc.decr("count", 1)); // now get the final stored value System.out.println("Get from Cache:"+mcc.get("count")); // now clear all this data System.out.println("Clear data:"+mcc.flush().isDone()); } }
Al compilar y ejecutar el programa, verá el siguiente resultado:
Connection to server successfully set status:true Get from Cache:5 Increment value:7 Decrement value:6 Get from Cache:6 Clear data:true
🚫