@param string     $key
@param string|int $min
@param string|int $max
@param bool       $withScores
@param int        $offset
@param int        $count

@return Promise
@yield array
978159
public function zRangeByScore($key, $min = 0, $max = -1, $withScores = false, $offset = null, $count = null) {
        $payload = ['zrangebyscore', $key, $min, $max];

        if ($withScores) {
            $payload[] = 'WITHSCORES';
        }

        if ($offset !== null && $count !== null) {
            $payload[] = 'LIMIT';
            $payload[] = $offset;
            $payload[] = $count;
        }

        return $this->send($payload, function ($response) use ($withScores) {
            if ($withScores) {
                $result = [];

                for ($i = 0, $count = \count($response); $i < $count; $i += 2) {
                    $result[$response[$i]] = $response[$i + 1];
                }

                return $result;
            }

            return $response;
        });
    }
487360
public function increment($key, $offset = 1)
    {
        $duration = $this->_config['duration'];
        $key = $this->_key($key);

        $value = (int)$this->_Redis->incrBy($key, $offset);
        if ($duration > 0) {
            $this->_Redis->setTimeout($key, $duration);
        }

        return $value;
    }
1079889
public function lrem($key, $count, $value) {
        return $this->returnCommand(['LREM'], $key, [$key, $count, $value]);
    }
111800
public function Loop($minSize = 1, $maxSize = null)
    {
        list($min, $max) = $this->resolveMinMax($minSize, $maxSize, 10);
        $limit = rand($min, $max);
        $list = ArrayList::create(array());
        $i = 0;
        while ($i < $limit) {
            $list->push(new DataObject());
            $i++;
        }

        return $list;
    }
352264
public function hmset($key) {

        $set     = $this->getKey($collection, $key, []);
        $args    = func_get_args();

        for ($i=1; $i<count($fields); $i++){
            $field = $args[$i];
            $value = isset($args[($i+1)]) ? $args[($i+1)] : null;

            $set[$field] = $value;
            $i = $i + 1;
        }

        $this->setKey($collection, $key, $set);
    }
257879
public function spop($key, $count = null) {
        $params = [$key];
        if ($count) {
            $params[] = $count;
        }
        return $this->returnCommand(['SPOP'], $key, $params);
    }
1106083
protected function buildException($key, $maxAttempts)
    {
        $retryAfter = $this->getTimeUntilNextRetry($key);

        $headers = $this->getHeaders(
            $maxAttempts,
            $this->calculateRemainingAttempts($key, $maxAttempts, $retryAfter),
            $retryAfter
        );

        return new ThrottleRequestsException(
            'Too Many Attempts.', null, $headers
        );
    }
1372938
protected function tooManyAttempts($key, $maxAttempts, $decayMinutes)
    {
        $limiter = new DurationLimiter(
            $this->redis, $key, $maxAttempts, $decayMinutes * 60
        );

        return tap(! $limiter->acquire(), function () use ($limiter) {
            [$this->decaysAt, $this->remaining] = [
                $limiter->decaysAt, $limiter->remaining,
            ];
        });
    }
583863
protected function cacheCountBetween($count, Carbon $from, Carbon $until, $locale, $cacheKey)
    {
        // Cache only if cacheKey is present
        if ($cacheKey && ($until->timestamp < Carbon::now()->timestamp))
        {
            $key = $this->makeBetweenCacheKey($from, $until, $locale, $cacheKey);

            $this->cache->put($key, $count, 525600);
        }
    }
216085
function group($key = null)
    {
        if (empty($key)) $key = sizeof($this->children);
        if (!isset($this->children[$key])){
            $this->children[$key] = new Trace($key, null);
        }
        return $this->children[$key];
    }
877660
public function hmSet($key, $fields)
    {
        if ($this->hasMaxSize()) {
            foreach ($fields as $field => $value) {
                try {
                    if ($this->isLarge($value)) {
                        $fields[$field] = $this->setLargeValue($this->getMappedKey($key, $field), $value, 0, false);
                    }
                } catch (common_Exception $e) {
                    common_Logger::w('Max size value is misconfigured: ' . $e->getMessage());
                }
            }
        }

        return $this->getDriver()->hmSet($key, $fields);
    }
585416
public function decrement($key, $offset = 1)
    {
        if (!$this->read($key)) {
            $this->write($key, 0);
        }
        $key = $this->_key($key);
        $this->data[$key]['val'] -= $offset;

        return $this->data[$key]['val'];
    }
582168
protected function determineKey($min, $max)
    {
        $minGiven = ($min !== null);
        $maxGiven = ($max !== null);

        if (!$minGiven && !$maxGiven) {
            throw new InvalidArgumentException('You must specify a valid value for min, max or both.');
        }

        if ($minGiven && !$maxGiven) {
            // Open end range.
            return $min . ':';
        } elseif (!$minGiven && $maxGiven) {
            // Open start range.
            return ':' . $max;
        }

        if ($min === $max) {
            // Exact number.
            return $min;
        }

        // Full defined range.
        return $min . ':' . $max;
    }
518790
public function get(string $key): Promise
    {
        try {
            $file = $this->cacheDir . urlencode($key);
            if (!file_exists($file)) {
                return Promise\resolve(null);
            }
            return Promise\resolve(unserialize(file_get_contents($file)));
        } catch (\Exception $e) {
            return Promise\resolve(null);
        }
    }
349266
private static function parseCronNumber($s, $min, $max): array
    {
        $result = array();
        $v1 = explode(",", $s);
        foreach ($v1 as $v2) {
            $v3 = explode("/", $v2);
            $step = empty($v3[1]) ? 1 : $v3[1];
            $v4 = explode("-", $v3[0]);
            $_min = count($v4) == 2 ? $v4[0] : ($v3[0] == "*" ? $min : $v3[0]);
            $_max = count($v4) == 2 ? $v4[1] : ($v3[0] == "*" ? $max : $v3[0]);
            for ($i = $_min; $i <= $_max; $i += $step) {
                if (intval($i) < $min) {
                    $result[$min] = $min;
                } elseif (intval($i) > $max) {
                    $result[$max] = $max;
                } else {
                    $result[$i] = intval($i);
                }
            }
        }

        ksort($result);

        return $result;
    }
237674
public function hscan($key, $cursor, $pattern = null, $count = null) {
        $params = [$key, $cursor];
        if (isset($pattern)) {
            $params[] = 'MATCH';
            $params[] = $pattern;
        }
        if (isset($count)) {
            $params[] = 'COUNT';
            $params[] = $count;
        }
        return $this->returnCommand(['HSCAN'], $key, $params);
    }
466392
public function retriesLeft($key, $maxAttempts)
    {
        $attempts = $this->attempts($key);

        return ($attempts === 0) ? $maxAttempts : $maxAttempts - $attempts + 1;
    }