cheprasov / php-redis-client

RedisClient is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from 2.6 to 6.0
MIT License
127 stars 41 forks source link

Variadic functions when array in arg #77

Closed MarcTCruz closed 4 years ago

MarcTCruz commented 4 years ago

This project seems pretty well developed and I guess it'll rock on PHP 8 where people will more and more write and seek for extensions written directly in php.

Here is my suggestion: Functions like hmget can easily become variadic to comply with Redis docs and without breaking changes for users like that:

    public function hmget($key, ...$fields) {
        if(is_array($fields[0]))
            $fields = $fields[0];
        return $this->returnCommand(['HMGET'], $key, [$key, (array) $fields]);
    }

This way, it can be called:

    $redis->hmget("key", "field1", "field2");
        or
    $redis->hmget("key", ["field1", "field2"]);
cheprasov commented 4 years ago

hi @MarcTCruz

Thanks a lot. Looks good. Current redis client support wide ranges of php versions (5.5 - 7.4). I am planning to stop support old php version and realise new redis client version only for php 7.4 +.

Thanks a lot :)