Skip to content

Internals Database Interface ICache

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

database\interface\ICache

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/database/interface/ICache.php · Snapshot 8411f4287706.

DatabaseManager delegates SQL generation to QueryBuilder, execution to IProvider, and result caching to ICache. Schema builders use MySQL DDL and the framework table registry.

ICache

Declaration and architectural role

interface ICache

Source description (behavioral corrections are recorded in Known discrepancies):

Contract for the query result cache.

The cache is keyed by (table, opaque query key). DatabaseManager includes SQL and bindings in that key. Fine-grained invalidation is driven by the raw WHERE conditions that were active when the query was cached, enabling column-value–level eviction (e.g. "invalidate everything cached for users WHERE name = 'Alice'").

Constants, enum cases, traits and properties

No own constants, enum cases, traits or property declarations. Inherited members are documented on the parent reference page.

Method index

Method Signature
get public function get(string $table, string $query): array|false
set public function set(string $table, string $query, array $result, array $conditions): void
invalidate public function invalidate(string $table, array $cudConditions): void
invalidateTable public function invalidateTable(string $table): void

get

Source line 23

public function get(string $table, string $query): array|false;

Parameters

Parameter Type, modifiers and default Purpose
$table string $table The primary table the query targets.
$query string $query The opaque query cache key.

Return cached rows for the given query, or false on a cache miss.

@param string $table The primary table the query targets. @param string $query The opaque query cache key.

@return array|false Cached rows on hit; false on miss.

Contract only: implementations supply the behavior. Parameter and return types are enforced by PHP; caller and implementation constraints follow the subsystem overview.

set

Source line 34

public function set(string $table, string $query, array $result, array $conditions): void;

Parameters

Parameter Type, modifiers and default Purpose
$table string $table The primary table.
$query string $query The opaque query cache key.
$result array $result The rows to cache.
$conditions array $conditions Raw column → value WHERE pairs (used for

Store query results together with the WHERE conditions that produced them.

@param string $table The primary table. @param string $query The opaque query cache key. @param array $result The rows to cache. @param array $conditions Raw column → value WHERE pairs (used for targeted invalidation later).

Contract only: implementations supply the behavior. Parameter and return types are enforced by PHP; caller and implementation constraints follow the subsystem overview.

invalidate

Source line 50

public function invalidate(string $table, array $cudConditions): void;

Parameters

Parameter Type, modifiers and default Purpose
$table string $table The table being mutated.
$cudConditions array $cudConditions Raw column → value pairs from the CUD WHERE clause.

Invalidate cached queries that overlap with the given CUD conditions.

Rules:

  • Queries cached without any WHERE conditions (full-table scans) are always invalidated on any CUD touching the same table.
  • Queries cached WITH conditions are invalidated when at least one column+value pair from $cudConditions matches their stored conditions.
  • When $cudConditions is empty (bulk / no-WHERE CUD), ALL cached queries for the table are invalidated.

@param string $table The table being mutated. @param array $cudConditions Raw column → value pairs from the CUD WHERE clause.

Contract only: implementations supply the behavior. Parameter and return types are enforced by PHP; caller and implementation constraints follow the subsystem overview.

invalidateTable

Source line 55

public function invalidateTable(string $table): void;

Parameters

Parameter Type, modifiers and default Purpose
$table string $table Operation input; the exact use, validation and propagation are shown in the implementation trace.

Unconditionally drop every cached entry for a table.

Contract only: implementations supply the behavior. Parameter and return types are enforced by PHP; caller and implementation constraints follow the subsystem overview.

Clone this wiki locally