Skip to content

Cache

This trait provides methods for caching data for the query.

  • Full name: \Zemit\Mvc\Controller\Traits\Query\Cache

Properties

cacheConfig

This variable holds the configuration settings for caching.

public \Phalcon\Support\Collection|null $cacheConfig

cacheKey

The cache key used for storing data in the cache.

public string|null $cacheKey

cacheLifetime

The lifetime of the cache data in seconds.

public int|null $cacheLifetime

Methods

initializeCacheConfig

Initializes the cache.

public initializeCacheConfig(): void

This method initializes the cache by setting the cache key and lifetime.

Throws:


initializeCacheLifetime

Initializes the cache lifetime.

public initializeCacheLifetime(): void

This method retrieves the 'lifetime' parameter using getParam() method, applies the 'FILTER_ABSINT' filter to it, and then sets the cache lifetime using setCacheLifetime() method with the filtered value.

Throws:


initializeCacheKey

Initializes the cache key based on the current parameters and user identity.

public initializeCacheKey(): void

This method generates a cache key by concatenating the user identity and a hash of the current parameters. The generated cache key is then set as the value of the cache key for the current instance of the object.


setCacheLifetime

Sets the cache lifetime.

public setCacheLifetime(int|null $cacheLifetime): void

Parameters:

Parameter Type Description
$cacheLifetime **int null**

getCacheLifetime

Retrieves the cache lifetime.

public getCacheLifetime(): int|null

Return Value:

The cache lifetime.


setCacheKey

Sets the cache key.

public setCacheKey(string|null $cacheKey): void

Parameters:

Parameter Type Description
$cacheKey **string null**

getCacheKey

Retrieves the cache key.

public getCacheKey(): string|null

Return Value:

The cache key.


setCacheConfig

Set the cache config collection for the query.

public setCacheConfig(\Phalcon\Support\Collection|null $cacheConfig): void

Parameters:

Parameter Type Description
$cacheConfig **\Phalcon\Support\Collection null**

getCacheConfig

Retrieves the cache collection for the query.

public getCacheConfig(): \Phalcon\Support\Collection|null

Return Value:

The cache config collection, or null if no cache is set.