WireDataDB::getCache()
Get and/or set cached value
Sets value from callable function and caches it so that later calls do not call the callable function again until it expires.
Available since version 3.0.258.
Example
// returns same random number for 1 hour (3600 seconds)
echo $page->meta->getCache('my_rand_num', 3600, function() {
return mt_rand();
}); Usage
$array = $wireDataDB->getCache(string $key, int $maxAge, callable $func);Arguments
| Name | Type(s) | Description |
|---|---|---|
$key | string | Name of property to get or set |
$maxAge | int | Maximum age in seconds |
$func | callable | Function that returns the value when creating (when new or after expiration) |
Return value
array mixed null
WireDataDB methods and properties
API reference based on ProcessWire core version 3.0.257