Rodniko
Rodniko

Reputation: 5124

store data inside WCF service and extract it later by the client

i have an Autocomplete ajax control that calls a WCF service method automatically. this method gets a string as an input parameter and return a list of strings. i don't make that call from the client , the control does it, but i write the content of this method.

Can i store some data somewhere in the WCF service when that method is called and extract it later when i use the WCF from the client ? i mean , i want the control to call the method, in the method i'll store some data and later when i use the WCF client object i'll extract it.

is there such "WCF cache" mechanism?

Upvotes: 0

Views: 1378

Answers (1)

Kirk Broadhurst
Kirk Broadhurst

Reputation: 28738

No, there's no such thing as a 'WCF cache' mechanism. But WCF is .NET, and in a .NET application you can use the Caching Application Block.

Caching has very little if anything to do with WCF. You cache inside your application, but the caching mechanism for a WCF service is fundamentally the same as a Windows Forms application or a managed Windows Service (or an ASMX webservice, or a ASP.NET application, or any .NET application). The only difference is how you use and rely on the cache & how the applicaton's lifecycle is managed.

If your WCF service is hosted in IIS (as is very popular), then when the application pool is recycled (or the website is restarted) you will lose everything in the cache. Will this be a problem?

The typical use case for a cache is when you have a set of data stored (in, say, a database) that will need to retrieved over and over again. Rather than get from the database everytime, you get from the cache. If it's not in the cache, you get from the database and put it in the cache so it's there for next time. It sounds like you want to store some data from the client application in the cache. You can do this, but what will happen if it's not there when you go to retrieve it.

Upvotes: 2

Related Questions