It worked for me...

This commit is contained in:
2025-05-13 18:23:37 -04:00
parent 3d94baf410
commit e2b10097aa
8 changed files with 154 additions and 15 deletions

52
src/Facades/Redis.php Normal file
View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace Siteworxpro\App\Facades;
use Illuminate\Support\Facades\Facade;
use Predis\Client;
use Predis\Response\Status;
/**
* Facade for the Redis client.
*
* This class provides a static interface to interact with the Redis client.
*
* @method static array scan($cursor, ?array $options = null)
* @method static string|null get(string $key)
* @method static Status|null set(string $key, $value, $expireResolution = null, $expireTTL = null, $flag = null)
* @method static array keys(string $pattern)
* @method static int del(string $key)
*/
class Redis extends Facade
{
public static function getFacadeRoot(): Client
{
if (self::$resolvedInstance !== null) {
$redis = self::resolveFacadeInstance(self::getFacadeAccessor());
if ($redis instanceof Client) {
return $redis;
}
}
// Create a new Redis client instance if not already resolved
return new Client([
'scheme' => 'tcp',
'host' => Config::get('redis.host'),
'port' => Config::get('redis.port'),
'database' => Config::get('redis.database'),
]);
}
/**
* Get the registered name of the component.
*
* @return string The name of the component.
*/
protected static function getFacadeAccessor(): string
{
return Client::class;
}
}