trait CollectionCacheTrait mixin Model

Trait CollectionCacheTrait can be applied to Model

Traits

Static Cache Trait Adds a static (per request) cache to the object which can hold data for the time of the request (in the frontend) or a certain duration during long running processes. It works together with the global caching system and enforces a static cache clearing in case of global cache clearings as well.

Methods

ModelCollection|$this[]
all(array $queryParams = [])

Returns all items of the model. Caches the collection at first call

ModelCollection|$this[]
find_all_by_id(array $ids, array $queryParams = [])

Wraps the find_all_by_id() method, to use the search_all_by_id() method on the cached model collection

Model|$this
find_by_id(int $id, array $queryParams = [])

Wraps the find_by_id() method, to use the search_by_id() method on the cached model collection

init($auto_load = true)

When trait is used in module, we need to apply a namespace

static void
static void
staticCacheClearCachePool($cache_pool = 'default')

Clears the specified cache pool from the static cache

static array|string|int|bool|null
staticCacheGet($key, string $cache_pool = 'default')

Retrieves a value from the static cache

static array
staticCacheGetKeys(string $cache_pool = 'default')

Returns an array of all cache keys which have been set

static array
staticCacheGetPool($cache_pool)

Returns an key/value array with all cached values from the passed pool

static bool
staticCacheIsEnabled()

No description

static bool
staticCacheIsSet($key, string $cache_pool = 'default')

Checks if the passed is key has a value set

static 
staticCacheRemove($key, string $cache_pool = 'default')

Removes the passed key

static void
staticCacheSet(string|int $key, mixed $value, string $cache_pool = 'default')

Store a value in the static cache

Details

at line 55
ModelCollection|$this[] all(array $queryParams = [])

Returns all items of the model. Caches the collection at first call

Parameters

array $queryParams

Optional query params, e.g order_by

Return Value

ModelCollection|$this[]

at line 95
ModelCollection|$this[] find_all_by_id(array $ids, array $queryParams = [])

Wraps the find_all_by_id() method, to use the search_all_by_id() method on the cached model collection

Parameters

array $ids

The ids

array $queryParams

Optional query params, e.g order_by

Return Value

ModelCollection|$this[]

at line 83
Model|$this find_by_id(int $id, array $queryParams = [])

Wraps the find_by_id() method, to use the search_by_id() method on the cached model collection

Parameters

int $id

Numeric Instance ID

array $queryParams

Optional query params, e.g order_by

Return Value

Model|$this

at line 28
init($auto_load = true)

When trait is used in module, we need to apply a namespace

Parameters

$auto_load

in StaticCacheTrait at line 121
static void staticCacheClearAllCachePools()

No description

Return Value

void

in StaticCacheTrait at line 114
static void staticCacheClearCachePool($cache_pool = 'default')

Clears the specified cache pool from the static cache

Parameters

$cache_pool

Return Value

void

in StaticCacheTrait at line 61
static array|string|int|bool|null staticCacheGet($key, string $cache_pool = 'default')

Retrieves a value from the static cache

Parameters

$key
string $cache_pool

Return Value

array|string|int|bool|null

Returns the cached result or null if no value has been stored

in StaticCacheTrait at line 98
static array staticCacheGetKeys(string $cache_pool = 'default')

Returns an array of all cache keys which have been set

Parameters

string $cache_pool

Return Value

array

in StaticCacheTrait at line 107
static array staticCacheGetPool($cache_pool)

Returns an key/value array with all cached values from the passed pool

Parameters

$cache_pool

Return Value

array

in StaticCacheTrait at line 34
static bool staticCacheIsEnabled()

No description

Return Value

bool

in StaticCacheTrait at line 85
static bool staticCacheIsSet($key, string $cache_pool = 'default')

Checks if the passed is key has a value set

Parameters

$key
string $cache_pool

Return Value

bool

in StaticCacheTrait at line 73
static staticCacheRemove($key, string $cache_pool = 'default')

Removes the passed key

Parameters

$key
string $cache_pool

in StaticCacheTrait at line 46
static void staticCacheSet(string|int $key, mixed $value, string $cache_pool = 'default')

Store a value in the static cache

Parameters

string|int $key
mixed $value
string $cache_pool

ID for the cache pool which should be used

Return Value

void