API / Minn\Content / RowCache

RowCache final class

Minn\Content\RowCache · public/minn/src/Minn/Content/RowCache.php · 100 lines

Rows read once a request: posts, their terms, users, and every object's meta, as the reference keeps them in its object cache, so a loop or a REST list does not read the same row once per use. A write to a table drops everything kept from it (Db::wrote, through the engine's own door or the facade's wpdb), as does a rolled-back transaction, so a read after a write finds the row as it now is. Nothing outlives the request.

Uses 1

Constants and properties

privateSOURCES = array ( 'posts' => array ( 0 => 'posts', ), 'post_terms' => array ( 0 => 'term_relationships', 1 => 'term_taxonomy', 2 => 'terms', ), 'revisions' => array ( 0 => 'posts', ), 'theme_templates' => array ( 0 => 'posts', 1 => 'term_relationships', 2 => 'term_taxonomy', 3 => 'terms', ), 'users' => array ( 0 => 'users', ), 'comments' => array ( 0 => 'comments', ), 'comment_queries' => array ( 0 => 'comments', 1 => 'commentmeta', ), 'term_rows' => array ( 0 => 'terms', 1 => 'term_taxonomy', ), 'post_meta' => array ( 0 => 'postmeta', ), 'user_meta' => array ( 0 => 'usermeta', ), 'term_meta' => array ( 0 => 'termmeta', ), 'comment_meta' => array ( 0 => 'commentmeta', ), )

The tables each kind of entry is read from.

privatestatic array $entries
privatestatic bool $listening
privatestatic array $watched

Public

staticremember(string $kind, string|int $key, Closure $load): mixed#

The kept value of a kind for a key, read through $load the first time.

statichas(string $kind, string|int $key): bool#

Whether a value is kept.

staticpeek(string $kind, string|int $key): mixed#

A kept value, or null when there is none.

staticput(string $kind, string|int $key, mixed $value): void#

Keeps a value read elsewhere (a batch read for a whole list).

staticwatch(string $kind, string $table): void#

Has a kind named at run time (a plugin's meta type, whose table only the registration knows) dropped whenever that table is written, as the kinds above are by theirs.

staticforget(string $kind, string|int|null $key = NULL): void#

Drops one kept value, or every one of a kind.

staticflush(): void#

Drops everything kept.

Internals 1

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

privatelisten(): void#