Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added support of Predis library as storage adapter #127

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.

@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));

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

Successfully merging this pull request may close these issues.

4 participants