Skip to content

Implement GetServer(RedisKey, ...) #2936

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

mgravell
Copy link
Collaborator

- implement memoization on GetServer when asyncState is null
- fixup NotImplementedException in dummy places
/// <param name="args">The arguments to pass for the command.</param>
/// <returns>A dynamic representation of the command's result.</returns>
/// <remarks>This API should be considered an advanced feature; inappropriate use can be harmful.</remarks>
RedisResult Execute(int? database, string command, params object[] args);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should database be nullable here? If you're using this overload, null should never be acceptable right? I'm curious if that removes the need for RS0026/RS0027 suppression

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Discussed in more depth in #2932, but short answer: "it is intentional"; null here means "behave the same as GetDatabase(...) does if you don't add a default" - very intentionally this is a database-oriented command, but using the configured default database. The parameters are ordered this way to avoid any ambiguity vs the command, i.e. it can't be optional because it is first, and we need command, and if we reversed the order it would be ambiguous vs string, params object[].

}

public RedisResult Execute(int? database, string command, params object[] args)
=> Execute(database, command, args, flags: CommandFlags.None);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should add this overload at all, given you can do [arg1, arg2, arg3] etc. so cleanly in current C#. Perhaps we stop adding these types of overloads?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

agreed and done; that removed the need for #pragma, too; win:win

@NickCraver
Copy link
Collaborator

Main feedback: the RS0026/RS0027 suppression gives me pause here, since that's commonly a source of feedback especially with null calls. Potentially separately or on top the params object[] and ICollection<object> overloads I think maybe are something we should avoid given C# advances allowing terse calls to do the same thing now (generating the params overload effectively). If users can do Method(argA, argB, [param, param2, param3]) these days, IMO we should avoid the overload ambiguity and chance for user error...but maybe I'm missing a major case - thoughts?

@mgravell
Copy link
Collaborator Author

mgravell commented Aug 8, 2025

OK to tick with the params removal (after fighting the tests for a bit)?

/// <param name="flags">The flags to use for this operation.</param>
/// <returns>A dynamic representation of the command's result.</returns>
/// <remarks>This API should be considered an advanced feature; inappropriate use can be harmful.</remarks>
RedisResult Execute(int? database, string command, ICollection<object> args, CommandFlags flags = CommandFlags.None);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the pragma needed here, if database isn't nullable?

@mgravell
Copy link
Collaborator Author

mgravell commented Aug 8, 2025

Removed; still Todo: think more about the dB Vs non-db execute naming

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

Successfully merging this pull request may close these issues.

2 participants