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 for hash field expiration commands #1456

Draft
wants to merge 12 commits into
base: v2.x
Choose a base branch
from

Conversation

vladvildanov
Copy link
Contributor

@vladvildanov vladvildanov commented Apr 29, 2024

This PR adds new commands operates on hash field expiration functionality

@vladvildanov vladvildanov requested review from tillkruss and a team as code owners April 29, 2024 12:37
@vladvildanov vladvildanov marked this pull request as draft April 29, 2024 12:37
@vladvildanov
Copy link
Contributor Author

vladvildanov commented Apr 29, 2024

PR still on draft, until:

  • Redis unstable docker image will support given functionality

@coveralls
Copy link

coveralls commented Apr 29, 2024

Coverage Status

coverage: 80.384% (+0.1%) from 80.289%
when pulling c522417 on vladvildanov:vv-hash-field-expiration
into cbef710 on predis:v2.x.

@@ -165,7 +175,10 @@
* @method $this hrandfield(string $key, int $count = 1, bool $withValues = false)
* @method $this hscan($key, $cursor, array $options = null)
* @method $this hset($key, $field, $value)
* @method $this hsetf(string $key, array $keyValuePairs, HSetFArguments $arguments = null)
Copy link

Choose a reason for hiding this comment

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

Call keyValuePairs dictionary, like in hmset?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense

/**
* Set the modifier that defines a behaviour on expiration.
*
* NX for each specified field set expiration only when the field has no expiration
Copy link

Choose a reason for hiding this comment

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

Being picky here, missing end dot at two sentences. And some more at the other method below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it

/**
* @var array
*/
protected $expireModifierEnum = [
Copy link

Choose a reason for hiding this comment

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

In my mind these two don't belong together. The {NX,XX,GT,LT} set is for overwriting rules, while {EX,PX,EXAT,PXAT} are basically just parameter name in compact form. For example {NX,XX,GT,LT} applies to other hash expiration commands, while the other set does not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So something like overrideModifierEnum sounds better?

Copy link

Choose a reason for hiding this comment

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

It's fine. I think my original point was to split the class in two, but on second thought I'm not sure it's worth it.

*/
public function setPersist(): self
{
if (!empty(array_intersect($this->ttlModifierEnum, $this->arguments))) {
Copy link

Choose a reason for hiding this comment

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

What if someone first calls setPersist and then calls setTtlModifier?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, let's add the same kind of check on the other side

src/Command/Redis/HEXPIRETIME.php Show resolved Hide resolved
@@ -72,7 +72,7 @@ class MasterSlaveReplication implements ReplicationInterface
/**
* {@inheritdoc}
*/
public function __construct(ReplicationStrategy $strategy = null)
public function __construct(?ReplicationStrategy $strategy = null)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's already a PR with this changes, I'm waiting for approval and then rebase this branch

@@ -72,7 +72,7 @@ class MasterSlaveReplication implements ReplicationInterface
/**
* {@inheritdoc}
*/
public function __construct(ReplicationStrategy $strategy = null)
public function __construct(?ReplicationStrategy $strategy = null)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's already a PR with this changes, I'm waiting for approval and then rebase this branch

Copy link

@gerzse gerzse left a comment

Choose a reason for hiding this comment

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

Looks good to me. I can't use the "Approve" button, but consider this approved from my side.

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

Successfully merging this pull request may close these issues.

None yet

4 participants