nikolaposa / rate-limit

🚔 General purpose rate limiter implementation.
MIT License
271 stars 47 forks source link

Redis Not connecting #30

Closed mitmelon closed 4 years ago

mitmelon commented 4 years ago

This is because Redis was initialised without being connected...

Solution

//Updated at class RedisRateLimiter
public function __construct(Redis $redis, string $keyPrefix = '')
    {
        $redis->connect('127.0.0.1',6379);
        $this->redis = $redis;
        $this->keyPrefix = $keyPrefix;
    }
nikolaposa commented 4 years ago

Solution is to inject properly configured (connected) Redis instance into RedisRateLimiter. Depending on the setup that will be different host/port. Redis configuration is out of rate limiter scope.