* @param int $flags Bitfield of BagOStuff::WRITE_* constants
* @return bool Success
*/
- protected function mergeViaCas( $key, $callback, $exptime = 0, $attempts = 10, $flags = 0 ) {
+ final protected function mergeViaCas( $key, callable $callback, $exptime, $attempts, $flags ) {
do {
$casToken = null; // passed by reference
// Get the old value and CAS token from cache
/**
* Delete all objects expiring before a certain date.
* @param string|int $timestamp The reference date in MW or TS_UNIX format
- * @param callable|null $progressCallback Optional, a function which will be called
+ * @param callable|null $progress Optional, a function which will be called
* regularly during long-running operations with the percentage progress
* as the first parameter. [optional]
* @param int $limit Maximum number of keys to delete [default: INF]
*
- * @return bool Success, false if unimplemented
+ * @return bool Success; false if unimplemented
*/
public function deleteObjectsExpiringBefore(
$timestamp,
- callable $progressCallback = null,
+ callable $progress = null,
$limit = INF
) {
- // stub
return false;
}
* @return bool Success
* @since 1.24
*/
- final public function setMulti( array $data, $exptime = 0, $flags = 0 ) {
+ public function setMulti( array $data, $exptime = 0, $flags = 0 ) {
if ( ( $flags & self::WRITE_ALLOW_SEGMENTS ) === self::WRITE_ALLOW_SEGMENTS ) {
throw new InvalidArgumentException( __METHOD__ . ' got WRITE_ALLOW_SEGMENTS' );
}
-
return $this->doSetMulti( $data, $exptime, $flags );
}
foreach ( $data as $key => $value ) {
$res = $this->doSet( $key, $value, $exptime, $flags ) && $res;
}
-
return $res;
}
* @return bool Success
* @since 1.33
*/
- final public function deleteMulti( array $keys, $flags = 0 ) {
+ public function deleteMulti( array $keys, $flags = 0 ) {
if ( ( $flags & self::WRITE_ALLOW_SEGMENTS ) === self::WRITE_ALLOW_SEGMENTS ) {
throw new InvalidArgumentException( __METHOD__ . ' got WRITE_ALLOW_SEGMENTS' );
}
-
return $this->doDeleteMulti( $keys, $flags );
}
foreach ( $keys as $key ) {
$res = $this->doDelete( $key, $flags ) && $res;
}
-
return $res;
}
* @param mixed $mainValue
* @return string|null|bool The combined string, false if missing, null on error
*/
- protected function resolveSegments( $key, $mainValue ) {
+ final protected function resolveSegments( $key, $mainValue ) {
if ( SerializedValueContainer::isUnified( $mainValue ) ) {
return $this->unserialize( $mainValue->{SerializedValueContainer::UNIFIED_DATA} );
}
* @param callable $workCallback
* @since 1.28
*/
- public function addBusyCallback( callable $workCallback ) {
+ final public function addBusyCallback( callable $workCallback ) {
$this->busyCallbacks[] = $workCallback;
}
*/
protected function debug( $text ) {
if ( $this->debugMode ) {
- $this->logger->debug( "{class} debug: $text", [
- 'class' => static::class,
- ] );
+ $this->logger->debug( "{class} debug: $text", [ 'class' => static::class ] );
}
}
* @param int $exptime
* @return bool
*/
- protected function expiryIsRelative( $exptime ) {
+ final protected function expiryIsRelative( $exptime ) {
return ( $exptime != 0 && $exptime < ( 10 * self::TTL_YEAR ) );
}
* @param int $exptime Absolute TTL or 0 for indefinite
* @return int
*/
- protected function convertToExpiry( $exptime ) {
- $exptime = (int)$exptime; // sanity
-
+ final protected function convertToExpiry( $exptime ) {
return $this->expiryIsRelative( $exptime )
? (int)$this->getCurrentTime() + $exptime
: $exptime;
* @param int $exptime
* @return int
*/
- protected function convertToRelative( $exptime ) {
- if ( $exptime >= ( 10 * self::TTL_YEAR ) ) {
- $exptime -= (int)$this->getCurrentTime();
- if ( $exptime <= 0 ) {
- $exptime = 1;
- }
- return $exptime;
- } else {
- return $exptime;
- }
+ final protected function convertToRelative( $exptime ) {
+ return $this->expiryIsRelative( $exptime )
+ ? (int)$exptime
+ : max( $exptime - (int)$this->getCurrentTime(), 1 );
}
/**
* @param mixed $value
* @return bool
*/
- protected function isInteger( $value ) {
+ final protected function isInteger( $value ) {
if ( is_int( $value ) ) {
return true;
} elseif ( !is_string( $value ) ) {
* @param BagOStuff[] $bags
* @return int[] Resulting flag map (class ATTR_* constant => class QOS_* constant)
*/
- protected function mergeFlagMaps( array $bags ) {
+ final protected function mergeFlagMaps( array $bags ) {
$map = [];
foreach ( $bags as $bag ) {
foreach ( $bag->attrMap as $attr => $rank ) {
public function deleteObjectsExpiringBefore(
$timestamp,
- callable $progressCallback = null,
+ callable $progress = null,
$limit = INF
) {
- $this->procCache->deleteObjectsExpiringBefore( $timestamp, $progressCallback, $limit );
+ $this->procCache->deleteObjectsExpiringBefore( $timestamp, $progress, $limit );
- return $this->backend->deleteObjectsExpiringBefore(
- $timestamp,
- $progressCallback,
- $limit
- );
+ return $this->backend->deleteObjectsExpiringBefore( $timestamp, $progress, $limit );
}
// These just call the backend (tested elsewhere)
return false;
}
- protected function doSet( $key, $value, $exp = 0, $flags = 0 ) {
+ protected function doSet( $key, $value, $exptime = 0, $flags = 0 ) {
return true;
}
return $result;
}
- public function doGetMulti( array $keys, $flags = 0 ) {
+ protected function doGetMulti( array $keys, $flags = 0 ) {
$this->debug( 'getMulti(' . implode( ', ', $keys ) . ')' );
foreach ( $keys as $key ) {
$this->validateKeyEncoding( $key );
return $this->checkResult( false, $result );
}
- public function doSetMulti( array $data, $exptime = 0, $flags = 0 ) {
+ protected function doSetMulti( array $data, $exptime = 0, $flags = 0 ) {
$this->debug( 'setMulti(' . implode( ', ', array_keys( $data ) ) . ')' );
foreach ( array_keys( $data ) as $key ) {
$this->validateKeyEncoding( $key );
return $this->checkResult( false, $result );
}
- public function doDeleteMulti( array $keys, $flags = 0 ) {
+ protected function doDeleteMulti( array $keys, $flags = 0 ) {
$this->debug( 'deleteMulti(' . implode( ', ', $keys ) . ')' );
foreach ( $keys as $key ) {
$this->validateKeyEncoding( $key );
);
}
- public function doGetMulti( array $keys, $flags = 0 ) {
+ protected function doGetMulti( array $keys, $flags = 0 ) {
foreach ( $keys as $key ) {
$this->validateKeyEncoding( $key );
}
public function deleteObjectsExpiringBefore(
$timestamp,
- callable $progressCallback = null,
+ callable $progress = null,
$limit = INF
) {
$ret = false;
foreach ( $this->caches as $cache ) {
- if ( $cache->deleteObjectsExpiringBefore( $timestamp, $progressCallback, $limit ) ) {
+ if ( $cache->deleteObjectsExpiringBefore( $timestamp, $progress, $limit ) ) {
$ret = true;
}
}
return $res;
}
- public function doSetMulti( array $data, $exptime = 0, $flags = 0 ) {
+ public function setMulti( array $data, $exptime = 0, $flags = 0 ) {
return $this->doWrite(
$this->cacheIndexes,
$this->usesAsyncWritesGivenFlags( $flags ),
);
}
- public function doDeleteMulti( array $data, $flags = 0 ) {
+ public function deleteMulti( array $data, $flags = 0 ) {
+ return $this->doWrite(
+ $this->cacheIndexes,
+ $this->usesAsyncWritesGivenFlags( $flags ),
+ __FUNCTION__,
+ func_get_args()
+ );
+ }
+
+ public function changeTTLMulti( array $keys, $exptime, $flags = 0 ) {
return $this->doWrite(
$this->cacheIndexes,
$this->usesAsyncWritesGivenFlags( $flags ),
throw new LogicException( __METHOD__ . ': proxy class does not need this method.' );
}
+ protected function doSetMulti( array $keys, $exptime = 0, $flags = 0 ) {
+ throw new LogicException( __METHOD__ . ': proxy class does not need this method.' );
+ }
+
+ protected function doDeleteMulti( array $keys, $flags = 0 ) {
+ throw new LogicException( __METHOD__ . ': proxy class does not need this method.' );
+ }
+
protected function serialize( $value ) {
throw new LogicException( __METHOD__ . ': proxy class does not need this method.' );
}
- protected function unserialize( $value ) {
+ protected function unserialize( $blob ) {
throw new LogicException( __METHOD__ . ': proxy class does not need this method.' );
}
}
return $result;
}
- protected function doSet( $key, $value, $expiry = 0, $flags = 0 ) {
+ protected function doSet( $key, $value, $exptime = 0, $flags = 0 ) {
list( $server, $conn ) = $this->getConnection( $key );
if ( !$conn ) {
return false;
}
- $expiry = $this->convertToRelative( $expiry );
+ $ttl = $this->convertToRelative( $exptime );
try {
- if ( $expiry ) {
- $result = $conn->setex( $key, $expiry, $this->serialize( $value ) );
+ if ( $ttl ) {
+ $result = $conn->setex( $key, $ttl, $this->serialize( $value ) );
} else {
// No expiry, that is very different from zero expiry in Redis
$result = $conn->set( $key, $this->serialize( $value ) );
return $result;
}
- public function doGetMulti( array $keys, $flags = 0 ) {
+ protected function doGetMulti( array $keys, $flags = 0 ) {
$batches = [];
$conns = [];
foreach ( $keys as $key ) {
return $result;
}
- public function doSetMulti( array $data, $expiry = 0, $flags = 0 ) {
+ protected function doSetMulti( array $data, $expiry = 0, $flags = 0 ) {
$batches = [];
$conns = [];
foreach ( $data as $key => $value ) {
return $result;
}
- public function doDeleteMulti( array $keys, $flags = 0 ) {
+ protected function doDeleteMulti( array $keys, $flags = 0 ) {
$batches = [];
$conns = [];
foreach ( $keys as $key ) {
public function deleteObjectsExpiringBefore(
$timestamp,
- callable $progressCallback = null,
+ callable $progress = null,
$limit = INF
) {
- return $this->writeStore->deleteObjectsExpiringBefore(
- $timestamp,
- $progressCallback,
- $limit
- );
+ return $this->writeStore->deleteObjectsExpiringBefore( $timestamp, $progress, $limit );
}
public function getMulti( array $keys, $flags = 0 ) {
: $this->readStore->getMulti( $keys, $flags );
}
- public function doSetMulti( array $data, $exptime = 0, $flags = 0 ) {
+ public function setMulti( array $data, $exptime = 0, $flags = 0 ) {
return $this->writeStore->setMulti( $data, $exptime, $flags );
}
- public function doDeleteMulti( array $keys, $flags = 0 ) {
+ public function deleteMulti( array $keys, $flags = 0 ) {
return $this->writeStore->deleteMulti( $keys, $flags );
}
+ public function changeTTLMulti( array $keys, $exptime, $flags = 0 ) {
+ return $this->writeStore->changeTTLMulti( $keys, $exptime, $flags );
+ }
+
public function incr( $key, $value = 1 ) {
return $this->writeStore->incr( $key, $value );
}
throw new LogicException( __METHOD__ . ': proxy class does not need this method.' );
}
+ protected function doSetMulti( array $keys, $exptime = 0, $flags = 0 ) {
+ throw new LogicException( __METHOD__ . ': proxy class does not need this method.' );
+ }
+
+ protected function doDeleteMulti( array $keys, $flags = 0 ) {
+ throw new LogicException( __METHOD__ . ': proxy class does not need this method.' );
+ }
+
protected function serialize( $value ) {
throw new LogicException( __METHOD__ . ': proxy class does not need this method.' );
}
return $success;
}
- protected function doSet( $key, $value, $expire = 0, $flags = 0 ) {
- $result = wincache_ucache_set( $key, $this->serialize( $value ), $expire );
+ protected function doSet( $key, $value, $exptime = 0, $flags = 0 ) {
+ $result = wincache_ucache_set( $key, $this->serialize( $value ), $exptime );
// false positive, wincache_ucache_set returns an empty array
// in some circumstances.
return $values;
}
- public function doSetMulti( array $data, $exptime = 0, $flags = 0 ) {
+ protected function doSetMulti( array $data, $exptime = 0, $flags = 0 ) {
return $this->modifyMulti( $data, $exptime, $flags, self::$OP_SET );
}
return (bool)$db->affectedRows();
}
- public function doDeleteMulti( array $keys, $flags = 0 ) {
+ protected function doDeleteMulti( array $keys, $flags = 0 ) {
return $this->modifyMulti(
array_fill_keys( $keys, null ),
0,
return $ok;
}
- public function changeTTLMulti( array $keys, $exptime, $flags = 0 ) {
+ protected function doChangeTTLMulti( array $keys, $exptime, $flags = 0 ) {
return $this->modifyMulti(
array_fill_keys( $keys, null ),
$exptime,
public function deleteObjectsExpiringBefore(
$timestamp,
- callable $progressCallback = null,
+ callable $progress = null,
$limit = INF
) {
/** @noinspection PhpUnusedLocalVariableInspection */
$this->deleteServerObjectsExpiringBefore(
$db,
$timestamp,
- $progressCallback,
+ $progress,
$limit,
$numServersDone,
$keysDeletedCount