TABLE
TABLE = 'strata_classification'
The table classifications live in.
Remembers what each part of the ephemeral keyspace has been decided to be.
Rows are keyed by PATTERN, not by key. A site with two million cache entries under cache_render
gets one row, and the volume is carried as counters on it. Storing a row per key would make the
classification table larger than the thing it describes.
A human decision is never overwritten by a rule. Heuristics runs on every discovery pass and
would otherwise re-derive its own answer over the top of a person's, silently, every cron. So a
row whose source is human is left alone by everything except another human. That asymmetry is
the whole reason this is stored rather than recomputed.
classify(string $key) : \Drupal\strata\Capture\Classifier\Classification
What a key is classified as.
A stored pattern wins over a rule, and the most specific stored pattern wins over a broader
one, so cache_render* decided by a human beats cache* derived by a rule.
| string | $key | The key or namespace. |
The classification.
undecided(int $limit = 50) : list<array<string,mixed>>
Patterns still waiting for a human decision, busiest first.
What the admin UI lists. Ordered by observed volume, because a pattern covering two million keys is the one worth deciding and a pattern covering three is not.
| int | $limit | Most rows to return. |
The rows.
observe(string $pattern, \Drupal\strata\Capture\Classifier\Classification $classification, int $keys, int $bytes) : void
Records what a discovery pass observed under a pattern.
The classification is only set when the pattern is new. An existing row keeps whatever it says, because it may hold a decision, and the counters are replaced rather than added to because a pass measures the whole keyspace rather than the change since the last one.
| string | $pattern | The pattern observed. |
| \Drupal\strata\Capture\Classifier\Classification | $classification | What the heuristics made of it, used only for a pattern not seen before. |
| int | $keys | Keys observed under it. |
| int | $bytes | Bytes observed under it. |
storedFor(string $key) : array{classification: \Drupal\strata\Capture\Classifier\Classification, source: string}|null
The most specific stored row covering a key.
| string | $key | The key or namespace. |
The row, or NULL when nothing stored covers it.
write(string $pattern, \Drupal\strata\Capture\Classifier\Classification $classification, string $source, int $keys, int $bytes, bool $keepCounters = false) : void
Writes one row.
| string | $pattern | The pattern. |
| \Drupal\strata\Capture\Classifier\Classification | $classification | The classification. |
| string | $source | Either Heuristics::SOURCE or Heuristics::HUMAN. |
| int | $keys | Keys observed. |
| int | $bytes | Bytes observed. |
| bool | $keepCounters | TRUE to leave the observed counters as they are, which a decision does: someone choosing a classification has not measured anything. |