\Drupal\strata\Cas DatabaseFrameIndex

The frame index a site runs on.

Deduplication only pays if the index outlives the request that built it: a frame written on Monday has to be recognised on Tuesday, or every flush re-uploads content the bucket already holds. The in-memory index is for a single process; this is the one a site uses.

Recording a frame is an upsert rather than a read followed by a write, so two concurrent flushes storing the same content cannot lose one another's reference.

Every row here is derived from the objects in the bucket and is rebuilt by strata:reindex, which is what makes it safe for an uninstall to drop the table.

Summary

Methods
Properties
Constants
__construct
has
get
record
relocate
reference
dereference
orphans
page
forget
dependents
deepestChains
dictionaries
clear
statistics
No public properties found
TABLE
No protected methods found
No protected properties found
No protected constants found
references
toRecord
database
No private constants found

Constant

TABLE

TABLE = 'strata_frame'

The table records 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 records are kept.

Returns

mixed —

has()

has(string  $hash) : bool

Whether the store already holds a frame.

Parameters

string $hash

Content address of the decoded frame.

Returns

bool —

TRUE when the frame is present and the pipeline can be skipped.

get()

get(string  $hash) : \Drupal\strata\Cas\FrameRecord|null

The record for a frame.

Parameters

string $hash

Content address of the decoded frame.

Returns

\Drupal\strata\Cas\FrameRecord|null —

The record, or NULL when the frame is unknown.

record()

record(\Drupal\strata\Cas\FrameRecord  $record) : \Drupal\strata\Cas\FrameRecord

Records a newly stored frame, or increments an existing one.

Parameters

\Drupal\strata\Cas\FrameRecord $record

The record.

Returns

\Drupal\strata\Cas\FrameRecord —

The stored record, with its resulting reference count.

relocate()

relocate(\Drupal\strata\Cas\FrameRecord  $record) : \Drupal\strata\Cas\FrameRecord

Replaces where a frame lives and how it is encoded, keeping its reference count.

Parameters

\Drupal\strata\Cas\FrameRecord $record

The record's new location and encoding. Its reference count is ignored in favour of the one already stored.

Returns

\Drupal\strata\Cas\FrameRecord —

The stored record, with the reference count it kept.

reference()

reference(string  $hash, int  $count = 1) : int

Adds references to a frame.

Parameters

string $hash

Content address of the decoded frame.

int $count

How many references to add.

Returns

int —

The resulting reference count, or 0 when the frame is unknown.

dereference()

dereference(string  $hash, int  $count = 1) : int

Removes references from a frame.

Parameters

string $hash

Content address of the decoded frame.

int $count

How many references to remove.

Returns

int —

The resulting reference count, never below zero.

orphans()

orphans(int  $limit = 1000) : list<\Drupal\strata\Cas\FrameRecord>

Frames nothing points at any more.

Parameters

int $limit

Most records to return.

Returns

list<\Drupal\strata\Cas\FrameRecord> —

Collectable records.

page()

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

One page of every frame the index holds, referenced or not, oldest first.

Parameters

int $limit

Most records to return.

int $offset

Records to skip.

Returns

list<\Drupal\strata\Cas\FrameRecord> —

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

forget()

forget(array  $hashes) : int

Removes records for frames that have been deleted from the store.

Parameters

array $hashes

Content addresses to forget.

Returns

int —

How many records were removed.

dependents()

dependents(string  $hash, int  $limit = 100) : list<\Drupal\strata\Cas\FrameRecord>

Frames that decode against a given frame.

Parameters

string $hash

Content address of the candidate parent.

int $limit

Most records to return, so the query stays bounded on a frame with many children.

Returns

list<\Drupal\strata\Cas\FrameRecord> —

Records naming this frame as their delta parent.

deepestChains()

deepestChains(int  $minimum, int  $limit = 100) : list<\Drupal\strata\Cas\FrameRecord>

Frames whose delta chains are at least a given depth, deepest first.

Parameters

int $minimum

Fewest links a chain must have to be returned. Zero returns every delta frame.

int $limit

Most records to return, so a pass over a store with many long chains stays bounded.

Returns

list<\Drupal\strata\Cas\FrameRecord> —

The records, deepest chain first.

dictionaries()

dictionaries() : array<string,int>

Dictionaries the store cannot decode without.

Returns

array

Dictionary id keyed to how many referenced frames need it. A dictionary absent from this map is not needed by anything that is still reachable.

clear()

clear() : int

Drops every record.

Returns

int —

How many records were removed.

statistics()

statistics() : array{frames: int, rawBytes: int, storedBytes: int, orphans: int, ratio: float}

What the store holds, for the settings form and the storage explorer.

Returns

array{frames: int, rawBytes: int, storedBytes: int, orphans: int, ratio: float} —

Frame count, decoded and stored byte totals, how many frames are collectable, and the overall compression ratio.

references()

references(string  $hash) : int

The current reference count for a frame.

Parameters

string $hash

Content address of the decoded frame.

Returns

int —

The count, or 0 when the frame is unknown.

toRecord()

toRecord(array  $row) : \Drupal\strata\Cas\FrameRecord

Builds a record from a database row.

Parameters

array $row

The row.

Returns

\Drupal\strata\Cas\FrameRecord —

The record.