feat: redis
This commit is contained in:
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Cache\Redis\Admin;
|
||||
|
||||
use App\Cache\Redis\RedisCache;
|
||||
use App\Constants\RedisCode;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
@@ -26,7 +27,7 @@ class UserCache
|
||||
*/
|
||||
public function getAdminToken($userId): false|string
|
||||
{
|
||||
return $this->redis->get(AdminRedisKey::adminUserToken($userId),'system') ?? false;
|
||||
return $this->redis->get(AdminRedisKey::adminUserToken($userId),RedisCode::SYSTEM_DB) ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,7 +42,7 @@ class UserCache
|
||||
public function setAdminToken($userId, string $token, int $ttl): bool
|
||||
{
|
||||
$key = AdminRedisKey::adminUserToken($userId);
|
||||
$this->redis->delete($key,'system');
|
||||
return $this->redis->setEx($key, $token, $ttl, 'system');
|
||||
$this->redis->delete($key,RedisCode::SYSTEM_DB);
|
||||
return $this->redis->setEx($key, $token, $ttl, RedisCode::SYSTEM_DB);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user