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

Extended set command to support SetOptions #879

Merged

Conversation

RokasVaitkevicius
Copy link
Contributor

Added new set command parameter: options which supports SET options described in Redis documentation: https://redis.io/commands/set/

Closes #876

@RokasVaitkevicius
Copy link
Contributor Author

I opened this to seek opinions and guidance on a couple of matters.

  1. I'm unsure how to maintain backward compatibility for the set function because my implementation requires users to add a new function parameter to their set calls. I see two possible approaches here: either leave it as incompatible or add a new set function with options. Alternatively, there might be a way to ensure compatibility that I've overlooked, because I'm relatively new to Rust. If so, let me know.
  2. I've introduced a new enum called SetExpiry, and it shares many values with the existing Expiry enum. Is it acceptable to keep them both, or should I extract the shared values into a separate enum? If extraction is recommended, how would you suggest accomplishing it?

Once these questions are answered, I'll make the necessary changes, add tests, and update the documentation. I didn't want to dive too deep into the implementation until these uncertainties were addressed. Thank you!

@nihohit
Copy link
Contributor

nihohit commented Jun 29, 2023

  1. IMO we should add a new function (set_ext/set_with_options?) instead of breaking backwards compatibility.
  2. IMO the enum should be separate, seeing as they have different values.

@jaymell
Copy link
Contributor

jaymell commented Jun 29, 2023

Yep, please no breakage here. set_options would probably be the closest we have to a standard name, given that the stream commands also use this naming approach.

@RokasVaitkevicius
Copy link
Contributor Author

RokasVaitkevicius commented Jun 29, 2023

Okay, I'll do that then, thanks.

@RokasVaitkevicius RokasVaitkevicius marked this pull request as ready for review June 29, 2023 21:47
@RokasVaitkevicius
Copy link
Contributor Author

@jaymell Should be good to go. Let me know what you think.

redis/src/commands/mod.rs Outdated Show resolved Hide resolved
@nihohit
Copy link
Contributor

nihohit commented Jun 30, 2023

not sure I like the upsert term - AFAIK it's from RDBMS, not the NoSQL world. maybe conditional_update, conditional_set?

@RokasVaitkevicius
Copy link
Contributor Author

RokasVaitkevicius commented Jun 30, 2023

Good call. I've ranamed it to conditional_set.

I've also renamed fetch to get, it's a bit more straightforward that way I think and it says what it does exactly - gets

@RokasVaitkevicius
Copy link
Contributor Author

RokasVaitkevicius commented Jun 30, 2023

Sorry, forgot to run fmt, now it should pass the checks

@jaymell
Copy link
Contributor

jaymell commented Jul 3, 2023

Thanks, this looks great! I'll leave it up to you, but might not be a bad idea to add a simple integration test of the command as well, just to cover all our bases.

@RokasVaitkevicius
Copy link
Contributor Author

@jaymell I've added more tests for set options struct.

Regarding integrations tests I have this one: https://github.com/RokasVaitkevicius/redis-rs/blob/50669d679e74656d6111f54588f548ed79f1849c/redis/tests/test_basic.rs#L1189

Is it sufficient or you want me to add more tests like this?

@jaymell
Copy link
Contributor

jaymell commented Jul 8, 2023

@jaymell I've added more tests for set options struct.

Regarding integrations tests I have this one: https://github.com/RokasVaitkevicius/redis-rs/blob/50669d679e74656d6111f54588f548ed79f1849c/redis/tests/test_basic.rs#L1189

Is it sufficient or you want me to add more tests like this?

This looks great. Please fix the outstanding lint issue and we'll get it merged 🙏

@RokasVaitkevicius
Copy link
Contributor Author

Linting issue fixed, need to add it as pre-commit hook or something :D

@jaymell jaymell merged commit 8605575 into redis-rs:main Jul 9, 2023
9 checks passed
@jaymell
Copy link
Contributor

jaymell commented Jul 9, 2023

Merged -- thanks again!

altanozlu pushed a commit to altanozlu/redis-rs that referenced this pull request Aug 16, 2023
Add `set_options`, which supports the full set of options
available for Redis `SET` command.
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.

Extending SET command to support more options
3 participants