X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2Fobjectcache%2FMemcachedClient.php;h=c3fcab94bd8ab8152c26800b616dbf9bd2c18ff8;hb=bf9c2b0cb30cbe994f3a1859cf46224dd52039e1;hp=59322b676a8afd4f17b1122be2483b8eef86fee5;hpb=541b2e7e5b7d08a3e5aab5210455800615209e19;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/objectcache/MemcachedClient.php b/includes/libs/objectcache/MemcachedClient.php index 59322b676a..c3fcab94bd 100644 --- a/includes/libs/objectcache/MemcachedClient.php +++ b/includes/libs/objectcache/MemcachedClient.php @@ -360,6 +360,48 @@ class MemcachedClient { return false; } + /** + * Changes the TTL on a key from the server to $time + * + * @param string $key Key + * @param int $time TTL in seconds + * + * @return bool True on success, false on failure + */ + public function touch( $key, $time = 0 ) { + if ( !$this->_active ) { + return false; + } + + $sock = $this->get_sock( $key ); + if ( !is_resource( $sock ) ) { + return false; + } + + $key = is_array( $key ) ? $key[1] : $key; + + if ( isset( $this->stats['touch'] ) ) { + $this->stats['touch']++; + } else { + $this->stats['touch'] = 1; + } + $cmd = "touch $key $time\r\n"; + if ( !$this->_fwrite( $sock, $cmd ) ) { + return false; + } + $res = $this->_fgets( $sock ); + + if ( $this->_debug ) { + $this->_debugprint( sprintf( "MemCache: touch %s (%s)", $key, $res ) ); + } + + if ( $res == "TOUCHED" ) { + return true; + } + + return false; + } + /** * @param string $key * @param int $timeout @@ -487,7 +529,7 @@ class MemcachedClient { */ public function get_multi( $keys ) { if ( !$this->_active ) { - return false; + return array(); } if ( isset( $this->stats['get_multi'] ) ) {