I have started writing an application which i want to use for fast searching through my data.
I started using the client from ServiceStack.Redis. (Got it via NuGet) Around this i wrote a little test app to insert 20k of company data records and now i'm querying this thing using the following code:
using (var companies = redisClient.As<Company>())
{
var companiesFound = companies.GetAll().Where(x => x.CompanyName.Contains(searchString));
dgvOutput.DataSource = companiesFound.ToList<Company>();
}
The Company class i use looks like this:
public class Company
{
public long Id { get; set; }
public string CompanyName { get; set; }
public string CompanyAddress { get; set; }
public string CompanyCity { get; set; }
}
This all works well, but i can't say that it's fast. Can anyone help me on what to do to get this thing running as fast as it can be? Indexes? Different type of queries? Better not use LINQ?
I found this Documentation:
https://github.com/ServiceStack/ServiceStack.Redis/wiki/IRedisClient
But it' s not an Linq Provider.
I didn't find a way to get companies filtered, you can only get all or one by Id.
So I think, in the beginning, you have to get all Companies. And store it in application cache, maybe on Startup of your application
companies = redisClient.As<Company>().GetAll();
and then you can filter the List with Linq2Objects like you did before:
var companiesFound = companies.Where(x => x.CompanyName.Contains(searchString));
dgvOutput.DataSource = companiesFound;
I'm not sure if you need the ToList call.
Hopefully someone gives you a better solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With