if I understood correct , you can try this
Cache["CountryList" + CountryName] = your object whatever it is
by doing this , if your webservice returns data based on country name , then
it will define different versions of your queries by caching them.then you
can make a if/else block like this
if (Cache["CountryList" + CountryName]!=null)
{
return(Cache["CountryList" + CountryName])
}
else
{
//read from datasource
.....
//put into cache
Cache["CountryList" + CountryName]!=your object
}
The only thing you should care about is to put a string that is uniqe (for
ex. country name)
"Koen Hoorelbeke" <KoenHoorelbeke@discussions.microsoft.com> wrote in
message news:01021061-A7B1-47E6-B867-6DD7BAFF694B@microsoft.com...
[quoted text, click to view] > Hi there,
>
> Here's the situation: I have a webservice that calls an sql query and
> returns a table with data. This table doesn't change so much (actually
very
> little, maybe only once a month or so).
>
> However it contains data for multiple countries/states. So when I need the
> data, I have one parameter (the country). And thus the outcome of the
query
> can be as different as there are countries/states in the world.
>
> So if I want to cache the output (put the dataset in the cache), I kind of
> need a different cache-object for each possible country (and I don't know
> which countries will be input parameters).
>
> How do I do this best? Can I dynamically make cache objects?
>
> Preferably I'd like to have a cache-object for each country. Get the
dataset
> out of it, and do my thing. But as I look at it now, it seems that I have
to
> manually define a cache-object for each country ... and that's really a no
go
> (I don't even know how many countries there are in the world :-).
>
> And caching is a must, since this is a real busy webservice. Can't afford
to
> make that much unnecessary queries to my database-server (especially since
> it's not really necessary).
>
> How can I fix this? Any help, tips, suggestions would be very much
> appreciated !
>
> Thanks in advance.
>
> Greetingz,
> Koen Hoorelbeke
> abc123@noemail.nospam