test drive

This commit is contained in:
2025-04-21 10:39:02 +05:00
parent 885dc939c6
commit 016ffd7614
10 changed files with 158 additions and 36 deletions

View File

@@ -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
);
}