- handleCaching now supports an array of string (which will be glued together)

This commit is contained in:
Dave Mc Nicoll 2023-01-27 15:45:40 +00:00
parent 8665e97a19
commit 43c0627319

@ -8,10 +8,14 @@ trait HandleCacheTrait
{
protected ? CacheInterface $cache;
protected function handleCaching(string $key, callable $callback, null|int|\DateInterval $ttl = null) : mixed
protected function handleCaching(string|array $key, callable $callback, null|int|\DateInterval $ttl = null) : mixed
{
static $internalCache = [];
if (is_array($key)) {
$key = implode('.', $key);
}
if ( isset($internalCache[$key]) ) {
return $internalCache[$key];
}