dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
objectcache: improve BagOStuff arithmetic method signatures
[lhc/web/wiklou.git]
/
includes
/
libs
/
objectcache
/
RESTBagOStuff.php
diff --git
a/includes/libs/objectcache/RESTBagOStuff.php
b/includes/libs/objectcache/RESTBagOStuff.php
index
a10d1a4
..
82b5ac0
100644
(file)
--- a/
includes/libs/objectcache/RESTBagOStuff.php
+++ b/
includes/libs/objectcache/RESTBagOStuff.php
@@
-44,7
+44,7
@@
use Psr\Log\LoggerInterface;
* $wgSessionCacheType = 'sessions';
* @endcode
*/
* $wgSessionCacheType = 'sessions';
* @endcode
*/
-class RESTBagOStuff extends BagOStuff {
+class RESTBagOStuff extends
MediumSpecific
BagOStuff {
/**
* Default connection timeout in seconds. The kernel retransmits the SYN
* packet after 1 second, so 1.2 seconds allows for 1 retransmit without
/**
* Default connection timeout in seconds. The kernel retransmits the SYN
* packet after 1 second, so 1.2 seconds allows for 1 retransmit without
@@
-79,6
+79,7
@@
class RESTBagOStuff extends BagOStuff {
private $extendedErrorBodyFields;
public function __construct( $params ) {
private $extendedErrorBodyFields;
public function __construct( $params ) {
+ $params['segmentationSize'] = $params['segmentationSize'] ?? INF;
if ( empty( $params['url'] ) ) {
throw new InvalidArgumentException( 'URL parameter is required' );
}
if ( empty( $params['url'] ) ) {
throw new InvalidArgumentException( 'URL parameter is required' );
}
@@
-146,7
+147,7
@@
class RESTBagOStuff extends BagOStuff {
return false;
}
return false;
}
- p
ublic function s
et( $key, $value, $exptime = 0, $flags = 0 ) {
+ p
rotected function doS
et( $key, $value, $exptime = 0, $flags = 0 ) {
// @TODO: respect WRITE_SYNC (e.g. EACH_QUORUM)
// @TODO: respect $exptime
$req = [
// @TODO: respect WRITE_SYNC (e.g. EACH_QUORUM)
// @TODO: respect $exptime
$req = [
@@
-163,7
+164,7
@@
class RESTBagOStuff extends BagOStuff {
return $this->handleError( "Failed to store $key", $rcode, $rerr, $rhdrs, $rbody );
}
return $this->handleError( "Failed to store $key", $rcode, $rerr, $rhdrs, $rbody );
}
- p
ublic function a
dd( $key, $value, $exptime = 0, $flags = 0 ) {
+ p
rotected function doA
dd( $key, $value, $exptime = 0, $flags = 0 ) {
// @TODO: make this atomic
if ( $this->get( $key ) === false ) {
return $this->set( $key, $value, $exptime, $flags );
// @TODO: make this atomic
if ( $this->get( $key ) === false ) {
return $this->set( $key, $value, $exptime, $flags );
@@
-172,7
+173,7
@@
class RESTBagOStuff extends BagOStuff {
return false; // key already set
}
return false; // key already set
}
- p
ublic function d
elete( $key, $flags = 0 ) {
+ p
rotected function doD
elete( $key, $flags = 0 ) {
// @TODO: respect WRITE_SYNC (e.g. EACH_QUORUM)
$req = [
'method' => 'DELETE',
// @TODO: respect WRITE_SYNC (e.g. EACH_QUORUM)
$req = [
'method' => 'DELETE',
@@
-187,11
+188,11
@@
class RESTBagOStuff extends BagOStuff {
return $this->handleError( "Failed to delete $key", $rcode, $rerr, $rhdrs, $rbody );
}
return $this->handleError( "Failed to delete $key", $rcode, $rerr, $rhdrs, $rbody );
}
- public function incr( $key, $value = 1 ) {
+ public function incr( $key, $value = 1
, $flags = 0
) {
// @TODO: make this atomic
$n = $this->get( $key, self::READ_LATEST );
if ( $this->isInteger( $n ) ) { // key exists?
// @TODO: make this atomic
$n = $this->get( $key, self::READ_LATEST );
if ( $this->isInteger( $n ) ) { // key exists?
- $n = max( $n +
intval( $value )
, 0 );
+ $n = max( $n +
(int)$value
, 0 );
// @TODO: respect $exptime
return $this->set( $key, $n ) ? $n : false;
}
// @TODO: respect $exptime
return $this->set( $key, $n ) ? $n : false;
}
@@
-199,6
+200,10
@@
class RESTBagOStuff extends BagOStuff {
return false;
}
return false;
}
+ public function decr( $key, $value = 1, $flags = 0 ) {
+ return $this->incr( $key, -$value, $flags );
+ }
+
/**
* Processes the response body.
*
/**
* Processes the response body.
*