J
jehugaleahsa
Hello:
I am writing a cute little class that will cache queries against a
database. Currently, I am implementing this by storing the command
text, parameter values and generated DataRows.
First of all, is there something that does this already?
Second, right now I use a struct called Result that looks like this:
private struct Result
{
public object[] ParameterValues;
public DataRow[] Rows;
}
I am looking up past queries by storing the queries in a
Dictionary<string, List<Result>>, where the string key is the command
text and the List<Result> value is a collection of all the parameter
values and the generated DataRows that have been queried thus far.
Is there a way to improve the performance of this search? I am looking
for ideas. Currently, I have to loop though all the Results in the
List<Result> and compare against each of the parameter values. Is
there a way to optimize this algorithm while keeping things generic? I
can't even go against a primary key, since this class is meant to work
with anything.
Essentially, this class is worthless if it takes longer to find the
cached results than it would be to just rehit the database.
Thanks,
Travis
I am writing a cute little class that will cache queries against a
database. Currently, I am implementing this by storing the command
text, parameter values and generated DataRows.
First of all, is there something that does this already?
Second, right now I use a struct called Result that looks like this:
private struct Result
{
public object[] ParameterValues;
public DataRow[] Rows;
}
I am looking up past queries by storing the queries in a
Dictionary<string, List<Result>>, where the string key is the command
text and the List<Result> value is a collection of all the parameter
values and the generated DataRows that have been queried thus far.
Is there a way to improve the performance of this search? I am looking
for ideas. Currently, I have to loop though all the Results in the
List<Result> and compare against each of the parameter values. Is
there a way to optimize this algorithm while keeping things generic? I
can't even go against a primary key, since this class is meant to work
with anything.
Essentially, this class is worthless if it takes longer to find the
cached results than it would be to just rehit the database.
Thanks,
Travis