From 1d23a840b3181da8b2a7a04c237ac6890229bea2 Mon Sep 17 00:00:00 2001 From: Stijn Van der Borght Date: Fri, 15 Feb 2019 16:31:42 +0000 Subject: [PATCH] add support for memcached flush_all command --- etc/php/pear/memcached.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/etc/php/pear/memcached.php b/etc/php/pear/memcached.php index 46413088..2123c799 100644 --- a/etc/php/pear/memcached.php +++ b/etc/php/pear/memcached.php @@ -529,6 +529,29 @@ class Memcached return $newVal; } + /** + * Flush the cache + * + * @return boolean + */ + public function flush() + { + $this->writeSocket('flush_all') ; + + $s = $this->readSocket(); + + if ('OK' == $s) { + $this->resultCode = Memcached::RES_SUCCESS; + $this->resultMessage = ''; + return true; + + } else { + $this->resultCode = Memcached::RES_FAILURE; + $this->resultMessage = 'Flush fail.'; + return false; + } + } + /** * Write data to socket *