0

My current Environment - .NET Core 2.1, Redis-Server/cli 3.2 on Windows Server

I am currently trying to insert a large number keys into redis using the StackExchange.Redis Driver in my .NET core console application like this:

foreach (var item in collection)
{
    var key = item.SomeKey;
    var value = item.SomeValue;
    //Tried Both Async and Sync
    redisDatabase.StringSetAsync(key, value);
    redisDatabase.StringSet(key, value);
}

Records are passed to the for-each in batches of 1000

My collection has close to 285000 records and therefore is inserting these many into the redis-server, but upon completion i can see only 250000 odd records in the database (after running the INFO redis-cli command).

Why is this happening?

I do know that for mass insertions it is better to go with the redis protocol but this is a temporary solution i need for now

1
  • Are there any duplicate keys in your collections? These duplicate keys will be overwritten. Commented Aug 28, 2018 at 11:10

1 Answer 1

0

Turns out that redis only accepts so many set requests and processes them at once. What turned out to be the solution in my case was limiting the number of set commands fired from my application.

Initially it was set to 1000 requests per iteration and when it was changed to 500 it inserted all without missing any insertions.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.