API / Minn\Admin / UploadsSize

UploadsSize final readonly class

Minn\Admin\UploadsSize · public/minn/src/Minn/Admin/UploadsSize.php · 93 lines

How much the uploads folder holds, as Minn Admin 0.43 works it out and shares it through the minn_admin_uploads_size transient: the cached figure in either shape it has had ({bytes, partial}, or a bare count from before the budget), else a walk only an administrator may start, one at a time behind a two-minute lock, stopped after four seconds and kept as partial for an hour instead of twelve.

Used by 1

Constants and properties

privateCACHE = '_transient_minn_admin_uploads_size'
privateEXPIRES = '_transient_timeout_minn_admin_uploads_size'
privateLOCK = 'minn_admin_uploads_size_lock'
privateBUDGET = 4.0
privatereadonly Minn\Content\Site $site

Promoted from the constructor.

privatereadonly Minn\Auth\Capabilities $capabilities

Promoted from the constructor.

privatereadonly string $dir

Promoted from the constructor.

Public

new__construct(Minn\Content\Site $site, Minn\Auth\Capabilities $capabilities, string $dir)#
methodlabel(int $userId): string#

The Media card's "N used" line, "over N used" for a walk cut short, or "" when the size is not known.

methodmeasure(int $userId): ?array#

The uploads size, cached or walked now.

@return array{bytes: int, partial: bool}|null null when nothing is known and this caller may not find out

Internals 3

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatecached(): ?array#
@return array{bytes: int, partial: bool}|null
privatelock(): bool#

Whether this request may walk: no other has started one in the last two minutes.

privatewalk(): array#
@return array{bytes: int, partial: bool}