test drive
This commit is contained in:
@@ -268,3 +268,21 @@ function dbTypeToPhp(string $type): string
|
||||
default => 'string',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Cached value
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param int $seconds
|
||||
*/
|
||||
function cached(string $name, mixed $value, int $seconds = 60): mixed
|
||||
{
|
||||
return cache()->has($name)
|
||||
? cache($name)
|
||||
: cache()->remember(
|
||||
key: $name,
|
||||
ttl: $seconds,
|
||||
callback: fn () => is_callable($value) ? call_user_func($value) : $value
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user