/**
* $params include:
* - caches: A numbered array of either ObjectFactory::getObjectFromSpec
- * arrays yeilding BagOStuff objects or direct BagOStuff objects.
+ * arrays yielding BagOStuff objects or direct BagOStuff objects.
* If using the former, the 'args' field *must* be set.
* The first cache is the primary one, being the first to
* be read in the fallback chain. Writes happen to all stores
* invalidation uses logical TTLs, invalidation uses etag/timestamp
* validation against the DB, or merge() is used to handle races.
* @param array $params
+ * @phan-param array{caches:array<int,array|BagOStuff>,replication:string} $params
* @throws InvalidArgumentException
*/
public function __construct( $params ) {
}
public function get( $key, $flags = 0 ) {
- if ( ( $flags & self::READ_LATEST ) == self::READ_LATEST ) {
+ if ( $this->fieldHasFlags( $flags, self::READ_LATEST ) ) {
// If the latest write was a delete(), we do NOT want to fallback
// to the other tiers and possibly see the old value. Also, this
// is used by merge(), which only needs to hit the primary.
$missIndexes[] = $i;
}
- if ( $value !== false
- && $missIndexes
- && ( $flags & self::READ_VERIFIED ) == self::READ_VERIFIED
+ if (
+ $value !== false &&
+ $this->fieldHasFlags( $flags, self::READ_VERIFIED ) &&
+ $missIndexes
) {
// Backfill the value to the higher (and often faster/smaller) cache tiers
$this->doWrite(
);
}
- public function incr( $key, $value = 1 ) {
+ public function incr( $key, $value = 1, $flags = 0 ) {
return $this->doWrite(
$this->cacheIndexes,
$this->asyncWrites,
);
}
- public function decr( $key, $value = 1 ) {
+ public function decr( $key, $value = 1, $flags = 0 ) {
return $this->doWrite(
$this->cacheIndexes,
$this->asyncWrites,
);
}
- public function incrWithInit( $key, $ttl, $value = 1, $init = 1 ) {
+ public function incrWithInit( $key, $exptime, $value = 1, $init = null, $flags = 0 ) {
return $this->doWrite(
$this->cacheIndexes,
$this->asyncWrites,
* @return bool
*/
protected function usesAsyncWritesGivenFlags( $flags ) {
- return ( ( $flags & self::WRITE_SYNC ) == self::WRITE_SYNC ) ? false : $this->asyncWrites;
+ return $this->fieldHasFlags( $flags, self::WRITE_SYNC ) ? false : $this->asyncWrites;
}
public function makeKeyInternal( $keyspace, $args ) {