56 if ( empty(
$params[
'url'] ) ) {
57 throw new InvalidArgumentException(
'URL parameter is required' );
59 if ( empty(
$params[
'client'] ) ) {
65 foreach ( [
'caBundlePath',
'proxy' ] as $key ) {
67 $clientParams[$key] =
$params[$key];
72 $this->client =
$params[
'client'];
84 $this->client->setLogger(
$logger );
87 protected function doGet( $key, $flags = 0, &$casToken =
null ) {
95 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->client->run(
$req );
96 if ( $rcode === 200 ) {
106 if ( $rcode === 0 || ( $rcode >= 400 && $rcode != 404 ) ) {
107 return $this->
handleError(
"Failed to fetch $key", $rcode, $rerr );
112 public function set( $key,
$value, $exptime = 0, $flags = 0 ) {
120 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->client->run(
$req );
121 if ( $rcode === 200 || $rcode === 201 || $rcode === 204 ) {
124 return $this->
handleError(
"Failed to store $key", $rcode, $rerr );
127 public function add( $key,
$value, $exptime = 0, $flags = 0 ) {
129 if ( $this->
get( $key ) ===
false ) {
136 public function delete( $key, $flags = 0 ) {
139 'method' =>
'DELETE',
142 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->client->run(
$req );
143 if (
in_array( $rcode, [ 200, 204, 205, 404, 410 ] ) ) {
146 return $this->
handleError(
"Failed to delete $key", $rcode, $rerr );
155 return $this->
set( $key, $n ) ? $n :
false;
169 $this->logger->error(
"$msg : ({code}) {error}", [
unserialize( $serialized)
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
Class representing a cache/ephemeral data store.
isInteger( $value)
Check if a value is an integer.
const READ_LATEST
Bitfield constants for get()/getMulti()
setLastError( $err)
Set the "last error" registry.
Class to handle multiple HTTP requests.
Interface to key-value storage behind an HTTP server.
setLogger(LoggerInterface $logger)
const DEFAULT_CONN_TIMEOUT
Default connection timeout in seconds.
incr( $key, $value=1)
Increase stored value of $key by $value while preserving its TTL.
add( $key, $value, $exptime=0, $flags=0)
Insert an item if it does not already exist.
const DEFAULT_REQ_TIMEOUT
Default request timeout.
doGet( $key, $flags=0, &$casToken=null)
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
processing should stop and the error should be shown to the user * false