Allow for Redis info arrays which use Clients and Server keys
| Q | A |
|---|---|
| Documentation | no |
| Bugfix | yes |
| BC Break | no |
| New Feature | no |
| RFC | no |
| QA | no |
Description
The Redis Check has been extended by including response time, number of connected clients and uptime.
(https://github.com/laminas/laminas-diagnostics/pull/57/files#diff-ae274e5d76cba73799bb44059a715045e3721dbe71f125ad128df5d2152c2a52)
However, the number of connected clients and uptime may need to be retrieved in slightly different ways, as the array structure returned by Predis\ClientInterface::info() can have different data structures.
The previous behaviour only allowed directly retrieving connected_clients and uptime_in_seconds from the array returned by Predis\ClientInterface::info(). The suggested changes allow for those keys residing in $array['Clients'] and $array['Server'] respectively, as was the case in my setup.
In my testing I used Redis V6.0.6 and Predis V1.1.10.
NB: The suggested change allows for both data structures of the info array.
@Ocramius I've reworked the changes a bit - they now include some missing checks/guards as Psalm helpfully commented on and the change now targets the 1.24.x branch which I've merged into my branch.
Wrt the 'needs unit test' label - the only way I could test this is by mocking Redis/ClientInterface which are obviously both not part of laminas-diagnostics. So that only provides false sense of security as they could change their API at any moment and the test would be none the wiser. Wdyt?
@Ocramius Could you have a look at this?
About testing, I wonder if we can perhaps really spin up a redis instance? :thinking:
Hi, I have the same issue, could it be merged? Thanks
Is it possible to finally fix this issue after more than a year, please? 🙏🏻
Setting up a testing scenario for specific Redis versions is not something I’m able to do unfortunately 🤷♂️
Also I’m currently not actively working on PHP projects anymore so I’m affraid I won’t be actively following this PR (especially after it has been up here for more than a year 😅)
I just ran into this. I can confirm that this fixes the bug throwing an error:
PHP WARNING: Undefined array key "connected_clients"
I'm running a Redis 6 setup using Redis extension locally for development and Predis on production. I copied these changes and it just works. Can we please merge this and provide an interface and/or tests in a follow up PR?