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

EVAL_RO & EVALSHA_RO commands #2168

Merged
merged 10 commits into from
Jan 4, 2023

Conversation

shacharPash
Copy link
Contributor

No description provided.

@shacharPash
Copy link
Contributor Author

Work in progress.

/// <seealso href="https://redis.io/commands/eval_ro"/>,
/// <seealso href="https://redis.io/commands/evalsha_ro"/>
/// </remarks>
RedisResult ScriptEvaluateRO(string script, RedisKey[]? keys = null, RedisValue[]? values = null, 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.

naming: we've usually tried to be explicit in the API, to trade brevity for clarity; if this RO is "read only", I suggest ScriptEvaluateReadOnly, although I almost wonder whether a CommandFlags makes sense (probably not)

@@ -1525,9 +1511,24 @@ public Task<RedisResult> ExecuteAsync(string command, ICollection<object>? args,
return ExecuteAsync(msg, ResultProcessor.ScriptResult, defaultValue: RedisResult.NullSingle);
}

public RedisResult ScriptEvaluate(string script, RedisKey[]? keys = null, RedisValue[]? values = null, CommandFlags flags = CommandFlags.None)
{
var command = ResultProcessor.ScriptLoadProcessor.IsSHA1(script) ? RedisCommand.EVALSHA : RedisCommand.EVAL;
Copy link
Collaborator

Choose a reason for hiding this comment

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

it feels like there's a lot of duplication going on here; maybe worth combining some of this (in particular the message building) via a private helper API that takes bool readOnly ? also some dup re the catch etc, but: ...

Copy link
Contributor Author

@shacharPash shacharPash Jun 22, 2022

Choose a reason for hiding this comment

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

I also do not like it that way, I tried to optimize this line but the problem is that the lines are not the same, in some of the lines you have to place the commands "EVAL/EVALSHA" and in some the commands "EVAL_RO/EVALSHA_RO"

I didn't understand your suggestion to use private helper API that takes bool readOnly, If this is still relevant despite what I have written I would like for you to elaborate further.

@shacharPash shacharPash marked this pull request as ready for review June 22, 2022 13:57
@shacharPash
Copy link
Contributor Author

There is a lot of errors in the tests file, I guess the problem is with my computer so I try to fix it before I write the tests to the commands I added, while you can review the code.

@chayim
Copy link

chayim commented Dec 7, 2022

@shacharPash This may have a better change of being addressed if there were unit tests. WDYT about contributing some?

@shacharPash
Copy link
Contributor Author

Hey @mgravell , I added some tests to the commands in this PR, I would appreciate it if you would take a look.

@NickCraver
Copy link
Collaborator

@shacharPash no ask at the moment, @mgravell is going to take a look at if this API surface area makes sense (given it's a subset of existing APIs which are a bit fractured)

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.

4 participants