\Drupal\strata\Tier DatabasePlacementIndex

The placement index a site runs on.

One row per object per tier, keyed on both, so adding a replica is an insert rather than a read-modify-write over a packed column and two concurrent migrations cannot lose one another's copy.

Every row is derived from the buckets and is rebuilt by TierPlacementRebuilder, so an uninstall dropping the table costs the next read one probe per tier and nothing else.

Summary

Methods
Properties
Constants
__construct
get
record
place
displace
forget
keysIn
page
clear
byTier
statistics
No public properties found
TABLE
No protected methods found
No protected properties found
No protected constants found
write
database
No private constants found

Constant

TABLE

TABLE = 'strata_placement'

The table rows live in.

Properties

$database

$database : \Drupal\Core\Database\Connection

Type

Connection

Methods

__construct()

__construct(\Drupal\Core\Database\Connection  $database) : mixed

Constructs an index.

Parameters

\Drupal\Core\Database\Connection $database

Where rows are kept.

Returns

mixed —

get()

get(string  $key) : \Drupal\strata\Tier\Placement|null

Where one object is.

Parameters

string $key

The object key.

Returns

\Drupal\strata\Tier\Placement|null —

The placement, or NULL when nothing has been recorded for that key. NULL means unknown, not absent; Placement::isEmpty() is what says every tier was asked and none had it.

record()

record(\Drupal\strata\Tier\Placement  $placement) : \Drupal\strata\Tier\Placement

Replaces what is known about one object.

Parameters

\Drupal\strata\Tier\Placement $placement

The placement. Tiers not named by it are removed, so this is how a rebuild writes an authoritative answer over a stale one.

Returns

\Drupal\strata\Tier\Placement —

The stored placement.

place()

place(string  $key, int  $tier, int  $bytes = 0) : \Drupal\strata\Tier\Placement

Adds one tier to what is known about an object.

Parameters

string $key

The object key.

int $tier

Tier index that holds it.

int $bytes

The object's size, or zero to keep whatever is recorded.

Returns

\Drupal\strata\Tier\Placement —

The resulting placement.

displace()

displace(string  $key, int  $tier) : \Drupal\strata\Tier\Placement

Removes one tier from what is known about an object.

Parameters

string $key

The object key.

int $tier

Tier index that no longer holds it.

Returns

\Drupal\strata\Tier\Placement —

The resulting placement, empty when that was the last tier holding it.

forget()

forget(array  $keys) : int

Forgets objects entirely.

Parameters

array $keys

Object keys.

Returns

int —

How many rows were removed.

keysIn()

keysIn(int  $tier, int  $limit = 1000, int  $offset = 0) : list<string>

Object keys one tier holds, in key order.

Parameters

int $tier

Tier index.

int $limit

Most keys to return.

int $offset

Keys to skip.

Returns

list

The keys.

page()

page(int  $limit = 1000, int  $offset = 0) : list<\Drupal\strata\Tier\Placement>

One page of every placement, in key order.

Parameters

int $limit

Most placements to return.

int $offset

Placements to skip.

Returns

list<\Drupal\strata\Tier\Placement> —

The page, empty once the offset is past the end.

clear()

clear() : int

Drops every row.

Returns

int —

How many rows were removed.

byTier()

byTier() : array<int,array{objects: int, bytes: int}>

What each tier holds.

Returns

array

Tier index keyed to how many objects it holds and how many bytes they occupy. A tier with nothing recorded is absent, so a report drawn from this shows the tiers in use.

statistics()

statistics() : array{objects: int, copies: int, bytes: int}

How many distinct objects and rows are held.

Returns

array{objects: int, copies: int, bytes: int} —

Distinct object keys, total placements across every tier, and the byte total counted once per object rather than once per copy.

write()

write(string  $key, int  $tier, int  $bytes, int  $recorded) : void

Writes one row.

Parameters

string $key

The object key.

int $tier

Tier index.

int $bytes

The object's size.

int $recorded

Unix timestamp.

Returns

void —