-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Implement GETEX command #1743
Implement GETEX command #1743
Conversation
Shuffled Version out of the flags
I see we need async tests here, but main point that I'm hung on is the API - want to sanity check method names. IMO, The async test versions are straightforward, but thoughts on overload nullability and general naming? cc @mgravell |
Calling with null for the Good point about consuming code being unclear; |
I'll work on getting this updated (my fault we haven't gotten to everything) as part of #2055. Current thinking here: slim down to only the |
It seems a shame to lose support for the EXAT/PXAT options, but if you think that's best I see no issue with it. Just to try and clarify some things again though: If I remember correctly my intent was to stay consistent with I think there's also still misunderstanding about 'removal' and the Maybe some example translations might help clarify my original intent |
@benbryant0 Okay I gotcha - yes good clarifications, and some was lost in merge noise here. Will absolutely re-evaluate with fresh eyes. I really appreciate the follow-up here. |
Note that this does NOT match KeyExpireAsync because that API isn't awesome - it overloads what (key, null) means twice to ambiguity, so the DateTime overload is not nullable here but we'll respect the DateTime.MaxValue path.
@benbryant0 Would you mind eyes on latest when time allows please? I didn't match There's code that can be shared here on converting to milliseconds but will do that in a follow-up PR to keep things tidy. Thanks for everything here, it's much appreciated! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @benbryant0 - looks pretty good, just a few things.
1: I think there should be another API specifically for persistence rather than passing in null. I worked backward a bit and read through the code rather than reading your back & forth, I think 3 methods per sync/async would make the most sense here. Fundamentally the command allows 3 things, persist a given amount of time, persist until a time, and persit indefinitely. So this should either be 1 enum Operated method
StringGetSetExpiry(RedisKey key, ExpiryType type, Timespan? timespan = null, Timestamp? timestamp = null, Commandflags flags = CommandFlags.None)
or just split it out into 3 methods, which IMO is cleaner and will result in fewer paths, and fewer need for the library to toss exceptions. Sort of thinking the null timespan setting it to persist forever is confusing (I might expect it to have some reasonable default value e.g. 60 seconds, or something configured).
2: There's some extra logic to pull out seconds vs milliseconds I don't think necessary, just use milliseconds, I believe Redis will just use Milliseconds regardless, and you're going to send a 64 bit integer no matter what.
3: Very minor stylistic comments (casing and Assertions) in the tests. Looks like there is one missing test to exercise the off-nominal ArgumentException
we're adding above.
LGTM! Thanks for taking another pass at it @NickCraver and applying all the suggestions. Such an improvement over the original. And thanks @slorello89 for the good input. I agree that a separate method would be nicer; but I think consistency is more important (and this is already a very big interface). Good point regarding ms vs seconds; if I had even thought of it I wouldn't have done it due to lack of experience with Redis, now I know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given there's agreement on the API, LGTM 👍
Resolves #1740
Should add support for all current options of GETEX.
Questionable (non-)decisions (opinions wanted!):
StringGet[Async]
as the behaviour is most similar to plainStringGet
and I think the added expiry functionality is communicated by the parameters.TimeSpan?
while the absolute overload takes non-nullableDateTime
. I don't like it, but I did this as I realised I'd have to cast to escape ambiguity:(TimeSpan?)null
🤮. But maybe consistency is more important?tests
folder and cried a little; I have no idea what I'm supposed to update there. I just bumped the Redis version inDockerfile
since Docker is easy and you seem to use it in your GitHub actions.Strings
, even though they involve expiry and the tests themselves go against the pattern in that file a bit. Felt better than bloating something catch-all likeBasicOps
.