X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2Fobjectcache%2FMemcachedClient.php;h=c3fcab94bd8ab8152c26800b616dbf9bd2c18ff8;hb=26b56403a1b31e16381ebe25e8df9afcfde36282;hp=668135d070ca49cd6f98f79ad621a57f78d07820;hpb=b9bd630052bbd179d6798eb2f7d6e81911b73765;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/objectcache/MemcachedClient.php b/includes/libs/objectcache/MemcachedClient.php index 668135d070..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