43 if ( empty(
$params[
'url'] ) ) {
44 throw new InvalidArgumentException(
'URL parameter is required' );
47 if ( empty(
$params[
'client'] ) ) {
50 $this->client =
$params[
'client'];
53 $this->url = rtrim(
$params[
'url'],
'/' ) .
'/';
63 protected function doGet( $key, $flags = 0 ) {
66 'url' => $this->url . rawurlencode( $key ),
69 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->client->run(
$req );
70 if ( $rcode === 200 ) {
71 if ( is_string( $rbody ) ) {
76 if ( $rcode === 0 || ( $rcode >= 400 && $rcode != 404 ) ) {
77 return $this->
handleError(
"Failed to fetch $key", $rcode, $rerr );
90 $this->logger->error(
"$msg : ({code}) {error}", [
107 public function set( $key,
$value, $exptime = 0, $flags = 0 ) {
110 'url' => $this->url . rawurlencode( $key ),
113 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->client->run(
$req );
114 if ( $rcode === 200 || $rcode === 201 ) {
117 return $this->
handleError(
"Failed to store $key", $rcode, $rerr );
126 public function delete( $key ) {
128 'method' =>
'DELETE',
129 'url' => $this->url . rawurlencode( $key ),
131 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->client->run(
$req );
132 if ( $rcode === 200 || $rcode === 204 || $rcode === 205 ) {
135 return $this->
handleError(
"Failed to delete $key", $rcode, $rerr );
unserialize( $serialized)
interface is intended to be more or less compatible with the PHP memcached client.
setLastError( $err)
Set the "last error" registry.
Class to handle concurrent HTTP requests.
Interface to key-value storage behind an HTTP server.
handleError( $msg, $rcode, $rerr)
Handle storage error.
string $url
REST URL to use for storage.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
this hook is for auditing only $req