vendor/codeages/rate-limiter/src/Storage/RedisStorage.php

(开头部分) 774B

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace Codeages\RateLimiter\Storage;

/**
 * @author Peter Chung <touhonoob@gmail.com>
 * @date May 16, 2015
 */
class RedisStorage implements Storage
{
    /**
     * @var \Redis
     */
    protected $redis;

    public function __construct($host = '127.0.0.1', $port = 6379)
    {
        $this->redis = new \Redis();
        if ($this->redis->connect($host, $port) === false) {
            throw new \RuntimeException("Cannot connect to redis server $host:$port");
        }
    }

    public function set($key, $value, $ttl)
    {
        return $this->redis->set($key, $value, $ttl);
    }

    public function get($key)
    {
        return $this->redis->get($key);
    }

    public function del($key)
    {
        return $this->redis->del($key);
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。