Skip to content

Added support of Predis library as storage adapter #127

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tworzenieweb
Copy link

@tworzenieweb tworzenieweb commented Sep 12, 2023

Since predis library is a well-known alternative to phpredis, I've decided to add an extension to Redis storage adapter.

Some properties and methods were changed to protected in order to handle slight differences between these 2 libs.

Mostly additional params are passed as an array in phpredis and as single arguments in predis.

Signed-off-by: Łukasz Adamczewski <tworzenieweb@gmail.com>
@mvhirsch
Copy link

I'm currently looking into adding RedisCluster support (see #153). Probably we could join forces by rewriting the Redis adapter and include the if/else for handling Predis transparently and hiding the complexity to any user (DX++). WDYT?

@mvhirsch mvhirsch mentioned this pull request Apr 24, 2024
@@ -586,7 +593,7 @@ private function collectGauges(bool $sortMetrics = true): array
sort($keys);
$gauges = [];
foreach ($keys as $key) {
$raw = $this->redis->hGetAll(str_replace($this->redis->_prefix(''), '', $key));
$raw = $this->redis->hGetAll(str_replace($this->prefix(''), '', $key));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->prefix('') is always an empty string for this adater, but $key contains the prefix to remove.
perhaps $this->removePrefixFromKey($key) was intended here ?
The same applies to collectHistograms, collectGauges

Suggested change
$raw = $this->redis->hGetAll(str_replace($this->prefix(''), '', $key));
$raw = $this->redis->hGetAll($this->removePrefixFromKey($key));

@@ -622,7 +629,7 @@ private function collectCounters(bool $sortMetrics = true): array
sort($keys);
$counters = [];
foreach ($keys as $key) {
$raw = $this->redis->hGetAll(str_replace($this->redis->_prefix(''), '', $key));
$raw = $this->redis->hGetAll(str_replace($this->prefix(''), '', $key));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$raw = $this->redis->hGetAll(str_replace($this->prefix(''), '', $key));
$raw = $this->redis->hGetAll($this->removePrefixFromKey($key));

@@ -403,7 +411,7 @@ private function collectHistograms(): array
sort($keys);
$histograms = [];
foreach ($keys as $key) {
$raw = $this->redis->hGetAll(str_replace($this->redis->_prefix(''), '', $key));
$raw = $this->redis->hGetAll(str_replace($this->prefix(''), '', $key));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$raw = $this->redis->hGetAll(str_replace($this->prefix(''), '', $key));
$raw = $this->redis->hGetAll($this->removePrefixFromKey($key));

@gms8994
Copy link

gms8994 commented Jan 13, 2025

Is there any update on this? I'd love to get support for Predis in here so that I can use some additional stuff in production.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants