ViewCache
in package
Table of Contents
Properties
- $_config : CacheConfig|null
- $_defaultTtl : int
- $_enabled : bool
- $_storage : ICacheStorage
Methods
- __construct() : mixed
- ViewCache constructor
- clear() : bool
- Clear all cache
- delete() : bool
- Delete cache entry
- exists() : bool
- Check if cache key exists
- gc() : int
- Run garbage collection to remove expired cache entries
- generateKey() : string
- Generate cache key from controller, view and data
- get() : string|null
- Get cached content
- isEnabled() : bool
- Check if cache is enabled
- set() : bool
- Set cached content
- setEnabled() : void
- Enable or disable cache
- filterSerializableData() : array<string|int, mixed>
- Filter out non-serializable data from array
- hashData() : string
- Hash data array for cache key
- shouldRunGc() : bool
- Check if garbage collection should run
Properties
$_config
private
CacheConfig|null
$_config
$_defaultTtl
private
int
$_defaultTtl
$_enabled
private
bool
$_enabled
$_storage
private
ICacheStorage
$_storage
Methods
__construct()
ViewCache constructor
public
__construct(ICacheStorage $storage[, bool $enabled = true ][, int $defaultTtl = 3600 ][, CacheConfig|null $config = null ]) : mixed
Parameters
- $storage : ICacheStorage
- $enabled : bool = true
- $defaultTtl : int = 3600
- $config : CacheConfig|null = null
clear()
Clear all cache
public
clear() : bool
Return values
booldelete()
Delete cache entry
public
delete(string $key) : bool
Parameters
- $key : string
Return values
boolexists()
Check if cache key exists
public
exists(string $key) : bool
Parameters
- $key : string
Return values
boolgc()
Run garbage collection to remove expired cache entries
public
gc() : int
Return values
int —Number of entries removed
generateKey()
Generate cache key from controller, view and data
public
generateKey(string $controller, string $view, array<string|int, mixed> $data) : string
Parameters
- $controller : string
- $view : string
- $data : array<string|int, mixed>
Return values
stringget()
Get cached content
public
get(string $key) : string|null
Parameters
- $key : string
Return values
string|nullisEnabled()
Check if cache is enabled
public
isEnabled() : bool
Return values
boolset()
Set cached content
public
set(string $key, string $content[, int|null $ttl = null ]) : bool
Parameters
- $key : string
- $content : string
- $ttl : int|null = null
Tags
Return values
boolsetEnabled()
Enable or disable cache
public
setEnabled(bool $enabled) : void
Parameters
- $enabled : bool
filterSerializableData()
Filter out non-serializable data from array
private
filterSerializableData(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
Return values
array<string|int, mixed>hashData()
Hash data array for cache key
private
hashData(array<string|int, mixed> $data) : string
Parameters
- $data : array<string|int, mixed>
Return values
stringshouldRunGc()
Check if garbage collection should run
private
shouldRunGc() : bool