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

adding bulkinsert support #246

Merged
merged 1 commit into from
Nov 4, 2022

Conversation

Jeevananthan-23
Copy link
Contributor

Close #238 - Adding a feature to Bulk Insert data into Redis with the help of pipelines.

/// </summary>
/// <param name="items">The items to insert.</param>
/// <returns>null.</returns>
Task BulkInsert(IEnumerable<T> items);
Copy link
Member

Choose a reason for hiding this comment

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

  1. This should yield the IDs of the items inserted into Redis. Not the full KeyNames, just the ids. That should be returned by the call to Set within the method.
  2. This should just be named Insert and should just overload the regular behavior.
  3. This should have an overload to accept a timespan so folks can do TTL with it.

Copy link
Contributor Author

@Jeevananthan-23 Jeevananthan-23 Nov 3, 2022

Choose a reason for hiding this comment

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

@slorello89, I got your point here this method should return List<string> ids this must be the behavior of the method but the issue is with Call to Set within this method. Because the method is a Task typo which accepts it not a string type.

 /// <inheritdoc/>
        public async Task<List<string>> Insert(IEnumerable<T> items, TimeSpan timeSpan)
        {
            var tasks = new List<Task<string>>();
            foreach (var item in items.Distinct())
            {
                tasks.Add(_connection.SetAsync(item, timeSpan));
            }

            await Task.WhenAll(tasks);
            var result = tasks.Select(x => x.Result).ToList();
            return result;
        }

@slorello89
Copy link
Member

@Jeevananthan-23 Thanks for submitting this, couple of comments about what the api should look like (also looks like a lot of stylistic stuff in the test class which distracts from what's going on in it).

@Jeevananthan-23 Jeevananthan-23 force-pushed the feature/bulkinsert branch 2 times, most recently from f3239f1 to e9559cd Compare November 3, 2022 12:09
Copy link
Member

@slorello89 slorello89 left a comment

Choose a reason for hiding this comment

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

LGTM 👍 thanks for submitting this @Jeevananthan-23 :)

@slorello89 slorello89 merged commit 2beb858 into redis:main Nov 4, 2022
@zulander1 zulander1 mentioned this pull request Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for bulk insert
2 participants