Skip to content

Commit

Permalink
feature: add Redis#getPersistentId
Browse files Browse the repository at this point in the history
Since we removed the magic which automagically set the persistent id to the options, this method is to provide the persistent id in case we connected to redis using the persistent flag.

If the persistent ID was provided via config, the ID from the config is returned. Otherwise, we return the persistent ID from `ext-redis`.
In case `update` flag is provided, the persistent ID is always returned from `ext-redis`.

Signed-off-by: Maximilian Bösing <[email protected]>
  • Loading branch information
boesing committed Jun 21, 2024
1 parent 58c225e commit 1b1f6aa
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,29 @@ public function getOptions(): RedisOptions
return $this->options;
}

public function getPersistentId(bool $update = false): ?string

Check failure on line 105 in src/Redis.php

View workflow job for this annotation

GitHub Actions / QA Checks (Psalm [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@v1, ...

PossiblyUnusedMethod

src/Redis.php:105:21: PossiblyUnusedMethod: Cannot find any calls to method Laminas\Cache\Storage\Adapter\Redis::getPersistentId (see https://psalm.dev/087)
{
$options = $this->getOptions();

if (!$options->isPersistent()) {

Check failure on line 109 in src/Redis.php

View workflow job for this annotation

GitHub Actions / QA Checks (PHPCodeSniffer [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Expected 1 space after NOT operator; 0 found
return null;
}

if ($update === false) {
$persistentId = $options->getPersistentId();
if ($persistentId !== null) {
return $persistentId;
}
}

$persistentId = $this->getRedisResource()->getPersistentID();
if (!is_string($persistentId)) {

Check failure on line 121 in src/Redis.php

View workflow job for this annotation

GitHub Actions / QA Checks (PHPCodeSniffer [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-ac...

Expected 1 space after NOT operator; 0 found
return null;
}

return $persistentId;
}

/**
* {@inheritDoc}
*/
Expand Down

0 comments on commit 1b1f6aa

Please sign in to comment.