\Drupal\strata\Storage\Plugin\Strata\Storage NullStorage

Accepts objects and stores nothing, recording what a real store would have been asked to hold.

This is what a dry run writes to. An administrator deciding whether to enable a realm can flush against this provider for a day and read the object count, the byte total and the largest object off it, without paying for the storage or the requests.

Reads fail. A store that returned an empty string for a frame it never held would let a restore appear to succeed against nothing, so NullStorage::get() raises with the key that was asked for.

Summary

Methods
Properties
Constants
id
label
capabilities
isReachable
unreachableReason
statistics
reset
put
get
stream
head
exists
delete
list
No public properties found
No public constants found
No protected methods found
No protected properties found
No protected constants found
drain
sizes
bytes
writes
deletes
No private constants found

Properties

$sizes

$sizes : array

Size of every object that was written, keyed by object key.

Type

array<string, int> —

$bytes

$bytes : int

Total bytes accepted.

Type

int

$writes

$writes : int

Objects accepted, counting a rewrite of the same key twice.

Type

int

$deletes

$deletes : int

Objects deleted.

Type

int

Methods

id()

id() : string

The plugin id this provider registers under.

Returns

string —

A short lowercase token such as "s3", "r2", "sftp" or "local".

label()

label() : string

Human-readable name for the settings form.

Returns

string —

The label.

capabilities()

capabilities() : \Drupal\strata\Storage\Capabilities

What this endpoint can do.

Returns

\Drupal\strata\Storage\Capabilities —

The capability set.

isReachable()

isReachable() : bool

Whether the endpoint is reachable and the credentials work.

Returns

bool —

TRUE when a request would succeed right now.

unreachableReason()

unreachableReason() : string|null

Why the endpoint is unreachable.

Returns

string|null —

A short human-readable reason, or NULL when it is reachable.

statistics()

statistics() : array{objects: int, bytes: int, writes: int, deletes: int, largest: int}

What a real store would now be holding.

Returns

array{objects: int, bytes: int, writes: int, deletes: int, largest: int} —

Distinct keys currently held, their total size, how many writes and deletes were seen, and the largest single object.

reset()

reset() : void

Forgets everything recorded so far.

Returns

void —

put()

put(string  $key, mixed  $body, array  $options = []) : \Drupal\strata\Storage\PutResult

Writes an object.

Parameters

string $key

Object key relative to the store root.

mixed $body

The bytes, or an open readable stream. A stream is read once and not rewound, so a caller that needs it again must seek itself.

array $options

Provider options. ifNoneMatch (write only when the key is absent) is honoured wherever Capabilities::$conditionalWrite is true. metadata, contentType and storageClass are honoured only by providers whose endpoint carries them; a provider that cannot store an option refuses the write rather than dropping it, because an object written without the metadata its reader expects is indistinguishable from a corrupt one. Nothing in the engine depends on user metadata: a stored object carries whatever a reader needs in its own bytes.

Returns

\Drupal\strata\Storage\PutResult —

What was written.

get()

get(string  $key, ?\Drupal\strata\Storage\ByteRange  $range = null) : string

Reads an object.

Parameters

string $key

Object key relative to the store root.

?\Drupal\strata\Storage\ByteRange $range

A byte range, or NULL for the whole object.

Returns

string —

The bytes.

stream()

stream(string  $key) : resource

Opens an object as a stream.

Parameters

string $key

Object key relative to the store root.

Returns

resource —

An open readable stream the caller must close.

head()

head(string  $key) : \Drupal\strata\Storage\ObjectMeta|null

Metadata for one object without reading it.

Parameters

string $key

Object key relative to the store root.

Returns

\Drupal\strata\Storage\ObjectMeta|null —

The metadata, or NULL when the object is absent. Absence is not an error, because every caller of this method is asking precisely in order to find out.

exists()

exists(string  $key) : bool

Whether an object exists.

Parameters

string $key

Object key relative to the store root.

Returns

bool —

TRUE when it is present.

delete()

delete(array  $keys) : int

Deletes objects.

Parameters

array $keys

Object keys relative to the store root.

Returns

int —

How many keys the endpoint accepted. A store that can tell an absent key from a removed one counts only what it removed; S3 reports success for an absent key and cannot distinguish, so it counts everything it was given. Do not read this as "how many existed" - a prune receipt counts from the frame index, which knows.

list()

list(string  $prefix = '', ?string  $cursor = null, int  $limit = 1000, ?string  $delimiter = null) : \Drupal\strata\Storage\ObjectPage

Lists one page of objects under a prefix.

Parameters

string $prefix

Key prefix relative to the store root; an empty string lists everything.

?string $cursor

Continuation token from a previous page, or NULL to start.

int $limit

Most objects to return in this page.

?string $delimiter

Grouping delimiter, or NULL for a flat listing.

Returns

\Drupal\strata\Storage\ObjectPage —

The page.

drain()

drain(resource  $stream) : int

Reads a stream to its end and reports how long it was.

The bytes are discarded, but the stream is still consumed so a caller that hands over a temporary file sees the same behaviour it would from a real store.

Parameters

resource $stream

An open readable stream.

Returns

int —

Bytes read.