<?php
/**
 * REDIS队列服务
 *
 * @author zhangdongying
 * @date   2023-02-28
 */
declare(strict_types=1);

namespace Meibuyu\Common\GlobalLog\Service;

use Hyperf\Redis\Redis;
use Psr\Container\ContainerInterface;

class RedisQueueService
{
    /**
     * REDIS实例
     */
    protected $redis;

    /**
     * 初始化
     *
     * @param ContainerInterface $container 容器实例
     * @throws \Throwable
     */
    public function  __construct(ContainerInterface $container)
    {
        $this->redis = $container->get(Redis::class);
    }

    /**
     * 添加到队列中
     *
     * @param string $queue 队列名称
     * @param string $data 数据
     * @return mixed
     * @throws \Exception
     */
    public function push(string $queue, string $data)
    {
        return $this->redis->lPush($queue, $data);
    }
}