perl client and flush_all

Patrick Michael Kane modus-memcache at pr.es.to
Wed Jan 26 15:08:46 PST 2005


Hello:

As near as I can tell, Cache::Memcached does not have a flush_all
method.  Find attached a patch that adds support for it.

If there is a version of the perl client that already supports it, I'd
appreciate the pointer.

Best,
-- 
Patrick Michael Kane
<modus at pr.es.to>
-------------- next part --------------
--- /root/.cpan/build/Cache-Memcached-1.14/Memcached.pm	Tue Jul 27 10:07:04 2004
+++ Memcached.pm	Wed Jan 26 15:06:20 2005
@@ -743,6 +743,22 @@
     return (crc32(shift) >> 16) & 0x7fff;
 }
 
+sub flush_all {
+    my Cache::Memcached $self = shift;
+
+    my $success = 1;
+
+    $self->init_buckets() unless $self->{'buckets'};
+    my @hosts = @{$self->{'buckets'}};
+    foreach my $host (@hosts) {
+        my $sock = $self->sock_to_host($host);
+        my @res = $self->run_command($sock, "flush_all\r\n");
+        $success = 0 unless (@res);
+    }
+
+    return $success;
+}
+
 # returns array of lines, or () on failure.
 sub run_command {
     my Cache::Memcached $self = shift;


More information about the memcached mailing list