class ModelCache

A Model cache that can speed up data retrieval from the database

Methods

save(Model $model)

Save a model in the database cache

mixed
get(string $type, int $id, mixed $default = null)

Get a model from the database cache

bool
has(string $type, int $id)

Find whether a model exists in the cache

array
all(string|null $type = null)

Get all the cached models

void
clear()

Remove all the entries from the cache

Details

at line line 29
Model save(Model $model)

Save a model in the database cache

Parameters

Model $model the model to save

Return Value

Model The stored model

at line line 50
mixed get(string $type, int $id, mixed $default = null)

Get a model from the database cache

Parameters

string $type The type of the model (Player, Team etc.)
int $id The database ID of the model
mixed $default What to return if the model doesn't exist in the cache

Return Value

mixed The Model if it exists in the cache, or $default if it wasn't found

at line line 67
bool has(string $type, int $id)

Find whether a model exists in the cache

Parameters

string $type The type of the model (Player, Team etc.)
int $id The database ID of the model

Return Value

bool True if it exists, false if not

at line line 77
array all(string|null $type = null)

Get all the cached models

Parameters

string|null $type A specific type of models to look for

Return Value

array

at line line 94
void clear()

Remove all the entries from the cache

Return Value

void