client = new MemCachedClientforWiki( $params ); $this->client->set_servers( $params['servers'] ); $this->client->set_debug( $params['debug'] ); } public function setDebug( $debug ) { $this->client->set_debug( $debug ); } public function get( $key ) { return $this->client->get( $this->encodeKey( $key ) ); } public function set( $key, $value, $exptime = 0 ) { return $this->client->set( $this->encodeKey( $key ), $value, $exptime ); } public function delete( $key, $time = 0 ) { return $this->client->delete( $this->encodeKey( $key ), $time ); } public function lock( $key, $timeout = 0 ) { return $this->client->lock( $this->encodeKey( $key ), $timeout ); } public function unlock( $key ) { return $this->client->unlock( $this->encodeKey( $key ) ); } public function add( $key, $value, $exptime = 0 ) { return $this->client->add( $this->encodeKey( $key ), $value, $exptime ); } public function replace( $key, $value, $exptime = 0 ) { return $this->client->replace( $this->encodeKey( $key ), $value, $exptime ); } public function incr( $key, $value = 1 ) { return $this->client->incr( $this->encodeKey( $key ), $value ); } public function decr( $key, $value = 1 ) { return $this->client->decr( $this->encodeKey( $key ), $value ); } /** * Get the underlying client object. This is provided for debugging * purposes. */ public function getClient() { return $this->client; } /** * Encode a key for use on the wire inside the memcached protocol. * * We encode spaces and line breaks to avoid protocol errors. We encode * the other control characters for compatibility with libmemcached * verify_key. We leave other punctuation alone, to maximise backwards * compatibility. */ public function encodeKey( $key ) { return preg_replace_callback( '/[\x00-\x20\x25\x7f]+/', array( $this, 'encodeKeyCallback' ), $key ); } protected function encodeKeyCallback( $m ) { return rawurlencode( $m[0] ); } /** * Decode a key encoded with encodeKey(). This is provided as a convenience * function for debugging. */ public function decodeKey( $key ) { return urldecode( $key ); } }