Reputation: 9611
My windows service is hosting WCF services.
From what I understand my wcf services can be a singleton or have it create new endpoints per client request.
And I understand from this, if it is singleton, any caching done inside a endpoint will behave different when compared to if the endpoints are generated per client request.
If I am wrong in the above setup, please correct me.
What caching options do I have?
Is it similar to the web where multiple requests which are new instances of web pages have a cache store that can be used application wide?
Upvotes: 3
Views: 580
Reputation: 1968
Take a look at
for your endpoint management.
It sums to:
Instance Management is a set of techniques helping us to bind all client requests to service instances governing which instance handles which request. In order to get familiar with all instance management modes we should take a brief overview on all of them. Basically there are three instance modes in WCF:
Per-Session instance mode
Per-Call instance mode
Singleton Instance Mode
What I've usually done in situations like this is an per-session instance-cache. (Of course it depends on what I'm trying to do).
I use a cache object as in the following:
Configuration GetCachedConfiguration()
{
// If there is no cached item, get it from the database first.
if (cachedConfiguration == null)
{
cachedConfiguration = ConfigurationData.GetConfigurationData();
}
return cachedConfiguration;
}
Where cachedConfiguration is my static cached object. This function acts as my accessor to configuration data (in this case).
Upvotes: 2
Reputation: 44931
The easiest thing to do is store cached data in static classes.
Upvotes: 1