php-redisearch icon indicating copy to clipboard operation
php-redisearch copied to clipboard

PHPRedis getClient only for v6+

Open inpresif opened this issue 2 years ago • 2 comments

Unfortunately, as a windows user for local dev there's no such version yet (5.3 or so is highest).

This means that the line: $client = $clientFacade->getClient(new \Redis(['host', 6379])); will not work, as the construct expects 0 values.

Tried this:

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$client = $clientFacade->getClient(new Redis($redis));

but that resolves to an error:

<br />
<b>Fatal error</b>:  Uncaught RedisException: Redis server went away in C:\Users\test.dev\redis\redisearch-macfja\vendor\macfja\redisearch\src\Redis\Client\PhpredisClient.php:53
Stack trace:
#0 C:\Users\test.dev\redis\redisearch-macfja\vendor\macfja\redisearch\src\Redis\Client\PhpredisClient.php(53): Redis-&gt;getOption(8)
#1 C:\Users\test.dev\redis\redisearch-macfja\vendor\macfja\redisearch\src\IndexBuilder.php(228): MacFJA\RediSearch\Redis\Client\PhpredisClient-&gt;execute(Object(MacFJA\RediSearch\Redis\Command\Create))
#2 C:\Users\test.dev\redis\redisearch-macfja\index.php(32): MacFJA\RediSearch\IndexBuilder-&gt;create(Object(MacFJA\RediSearch\Redis\Client\PhpredisClient))
#3 {main}
  thrown in <b>C:\Users\test.dev\redis\redisearch-macfja\vendor\macfja\redisearch\src\Redis\Client\PhpredisClient.php</b> on line <b>53</b><br />

Any tips?

inpresif avatar Feb 17 '23 18:02 inpresif

I didn't try it, but you should be able to just give the $redis of your example instead of wrapping it into a new Redis client:

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
// And any other commands needed to initialize the Redis client
// Like auth, setOption
$client = $clientFacade->getClient($redis);

MacFJA avatar Feb 18 '23 12:02 MacFJA

Thanks for the answer I appreciate that. I'll have a go at that, not sure if I tested that already.

Yesterday, I did install PRedis as well just to get ahead, then I realized redisearch is not supported for Windows either, so we're off to another issue to fix (probably Docker or in the worst case, develop on the server instead of locally).

Thanks again.

inpresif avatar Feb 18 '23 12:02 inpresif