\Drupal\strata\Tier Placement

Which tiers hold one object.

A set rather than a single value, because a replica tier and its neighbour hold the same key and both answers are true. One tier means the object moved; several mean it was copied.

This is a cache over the buckets, not the record. The truth is which bucket the key is actually in, and TieredProvider falls back to probing when there is no row here, so a lost table costs one extra request per miss rather than a lost object. TierPlacementRebuilder puts it back by listing each tier, which is what makes it safe for an uninstall to drop the table.

Summary

Methods
Properties
Constants
__construct
tiers
nearest
coldest
has
isReplicated
isEmpty
copies
with
without
withBytes
jsonSerialize
key
bytes
recorded
No public constants found
No protected methods found
No protected properties found
No protected constants found
No private methods found
tiers
No private constants found

Properties

$key

$key : string

Type

string

$bytes

$bytes : int

Type

int

$recorded

$recorded : int

Type

int

$tiers

$tiers : list

Tier indexes holding this object, ascending and unique.

Type

array<int, int> —

Methods

__construct()

__construct(string  $key, list  $tiers = [], int  $bytes = 0, int  $recorded = 0) : mixed

Constructs a placement.

Parameters

string $key

The object key, exactly as the bucket holds it.

list $tiers

Tier indexes. Sorted and deduplicated, so two callers that learned the same tiers in a different order produce the same record.

int $bytes

The object's size, for the per-tier totals a report shows.

int $recorded

Unix timestamp this placement was last written.

Throws

\InvalidArgumentException

When the key is empty, a tier index is negative, or the size is negative.

Returns

mixed —

tiers()

tiers() : list<int>

Every tier holding this object.

Returns

list

Tier indexes, nearest first.

nearest()

nearest() : int|null

The nearest tier holding it.

Returns

int|null —

The index, or NULL when nothing holds it.

coldest()

coldest() : int|null

The furthest tier holding it.

Returns

int|null —

The index, or NULL when nothing holds it.

has()

has(int  $tier) : bool

Whether one tier holds it.

Parameters

int $tier

Tier index.

Returns

bool —

TRUE when it does.

isReplicated()

isReplicated() : bool

Whether more than one tier holds it.

Returns

bool —

TRUE when there is a second copy.

isEmpty()

isEmpty() : bool

Whether nothing holds it.

A placement with no tiers is not the same as no placement at all: it records that every tier was asked and none had the object, which is the answer a verify pass needs to report rather than a gap to fill in.

Returns

bool —

TRUE when no tier holds it.

copies()

copies() : int

How many tiers hold it.

Returns

int —

The count.

with()

with(int  $tier, int  $at = 0) : self

The same placement with one more tier.

Parameters

int $tier

Tier index to add.

int $at

Unix timestamp to stamp the record with, or zero to keep the existing one.

Throws

\InvalidArgumentException

When the tier index is negative.

Returns

self —

A new placement.

without()

without(int  $tier, int  $at = 0) : self

The same placement with one tier removed.

Parameters

int $tier

Tier index to drop.

int $at

Unix timestamp to stamp the record with, or zero to keep the existing one.

Returns

self —

A new placement.

withBytes()

withBytes(int  $bytes) : self

The same placement with a different size.

Parameters

int $bytes

The object's size.

Throws

\InvalidArgumentException

When the size is negative.

Returns

self —

A new placement.

jsonSerialize()

jsonSerialize() : array<string,mixed>

{@inheritdoc}

Returns

array

The placement as a plain array.