-
Notifications
You must be signed in to change notification settings - Fork 41
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
Enhance code readability #241
Conversation
Fix some typos in the markdown files and run `dotnet format` on existing code.
Change the settings so that documentation is included in the build.
Add support for the BZMPOP command. This command is blocking on the server, so it goes against the current policy of the StackExchange.Redis library. Therefore make it obvious in the code documentation that attention must be given to the timeout in the connection multiplexer. The StackExchange.Redis library already defines a type for the payload returned by BZMPOP (which is the same as for ZMPOP), namely the SortedSetPopResult class. However, the constructor of that class is internal in the library, so we can't create instances of it. Therefore roll our out type for a <value, score> pair, and use Tuple to pair a key with a list of such <value, score> pairs.
…formance and memory usage
…ge foreach to linq expression
…sAsync.cs and JsonTests.cs
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.
Thank you!
A lot of good changes! 👍 👍
I have a question, some of the changes you made are also relevant to the other modules (topK, search, cuckooFilter, etc.), is there a reason why you didn't make changes there?
@@ -157,7 +157,7 @@ public interface IJsonCommandsAsync | |||
/// <param name="value">The value to increment by.</param> | |||
/// <returns>The new values after being incremented, or null if the path resolved a non-numeric.</returns> | |||
/// <remarks><seealso href="https://redis.io/commands/json.numincrby"/></remarks> | |||
Task<double?[]> NumIncrbyAsync(RedisKey key, string path, double value); | |||
Task<double?[]> NumIncrByAsync(RedisKey key, string path, double value); |
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.
- Its breaking change
- The sync command still called
NumIncrby
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.
Thank you for the feedback you gave me and the time you took to review
This is valuable for me
Actually, when I applied these changes, it was after work and I was very tired
I was reviewing the codes of this project out of curiosity and made some changes
To be honest, I am very interested in participating and contributing to this project
I will fix the problems you mentioned and I would be grateful if you check and give me feedback again
I can fix all the parts you mentioned
We can also communicate via email or wherever you prefer
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.
Hi Nima, I pushed a small commit reverting these ToString()
calls. It was easiest, given that it's a super small change. Thanks for your patience!
Improve the signatures of the new methods, to transparently replicate the structure of the Redis command, i.e. timeout is mandatory and the first argument, order is mandatory. Add a version of the method that works for a single argument, in the spirit of the StackExchange.Redis library.
Add a dedicated enum for the MIN and MAX arguments. It feels cleaner than using Order and having to mentally map Ascending to Min and Descending to Max.
The primary constructor syntax seems to be not supported by older dotnet versions, so don't use it. Also switch from `class` to `struct`, to better reflect the fact that RedisValueWithScore is just a data storage item.
It seems that workflows cancel each other out if they are in the same concurrency group: https://github.com/orgs/community/discussions/41518 Try to separate four workflows that run on PRs into separate concurency groups. Ideally this will avoid the cancelation. They should still cancel runs from previous pushes, each in their own group.
Collection literals are not supported by older dotnet versions, it seems, so stop using them for now.
Some tests (for the Gears module) seem flaky, they fails sometime with RedisTimeoutException. Try to double the timeout in the connection multiplexer, from 5 to 10 seconds, hopefully this helps.
@nimanikoo, did you see my comment? |
Hi dear @shacharPash , how are you? I read your comment and this conflict was on my local machine. Redis was running locally on my machine on port 6379 and it did not have a number of Redis stack modules and it was causing problems, I fixed this local conflict and the problem was solved.Currently, all the tests are passed correctly, except the tests related to the search, which @omidpakdel mentioned, and I have the same problem in branch Master for tests. |
to previous version becuase the old version of .net does not support the .net 8 syntax
Hey @nimanikoo, how are you? |
Hi @shacharPash ,How are you doing? |
@nimanikoo You can see the problematic sections in what failed the .NET 6 and 7 tests |
… constructor in .net 8
…llection literals'
…ror : error CS8652: The feature 'collection literals' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version
Hello @shacharPash , How are you doing? |
…cs for readonly strings
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.
Looks good to me. Two minor comments.
tests/Doc/StringSnippets.cs
Outdated
@@ -27,7 +27,7 @@ public void run() | |||
|
|||
// STEP_START set_get | |||
var res1 = db.StringSet("bike:1", "Deimos"); | |||
Console.WriteLine(res1); // true | |||
Console.WriteLine(res1.ToString()); // true |
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.
Isn't ToString()
implied here? These code snippets end up on the reddis.io web documentation, they should be as easy to read as possible.
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.
Hello Gabriel,
How are you?
Thanks for the points you mentioned.
I checked with branch master
and found that .ToString()
wasn't implemented, but I don't think it would cause any issues since it just logs.
Your opinion is still a priority, and if you agree, we can make some changes.
src/NRedisStack/Auxiliary.cs
Outdated
|
||
public static async Task<RedisResult> ExecuteAsync(this IDatabaseAsync db, SerializedCommand command) | ||
{ | ||
if (!_setInfo) return await db.ExecuteAsync(command.Command, command.Args); |
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.
In this class I find the original logic easier to read. Now the db.ExecuteAsync(...)
call is duplicated, so if we need to change it, it needs change in two places.
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.
It was a very good point. I fixed it. Thank you
Trying to keep code snippets as short as possible, since they get published on redis.io as documentation. Hence reverting the addition of the `ToString()` calls in some places.
Hello, I hope you are well
Thank you for helping open source and building this project for the .NET community
Out of curiosity, I was reviewing the codes of this repository and I found some points that might be good to correct.
One of the performance improvements was where you used lists
The next thing is that you can use the primary constructor according to the latest version of .NET
In some cases, we could have written the code in a more concise and readable manner and used expressions
There were several typo problems that I corrected
I hope these things are helpful and I will be happy to contribute to the progress of this project
Please check and let me know the result