Hi
thanks for ur reply.
But his example i found in msdn itself.
And it is stated that 'When caching is enabled requests and responses
are held in memory on the server for at least the cache duration '.
What i want is i have one method in web service for opening database
connection.
For getting information such as databsename, server name i am using
application variable along with cacheing.
And what i want is to keep this information into server for some
specific amount of time and then just clear that information from
server.
If i am doing wrong please let me know about that.
If u know any other alternative of doing this, then please let me know.
thanks in advance.
Jon Skeet [C# MVP] wrote:
archana wrote: I am having one web service in c#.net where in i am using
cacheduration.
I have one property as below:
[WebMethod(EnableSession=true, CacheDuration=20)]
get
{
return Application["MyServiceUsage"].ToString();
}
[WebMethod(EnableSession=true, CacheDuration=20)]
set
{
if (Application["MyServiceUsage"] == null)
{
Application["MyServiceUsage"] = value +
DateTime.Now.Minute.ToString(); ;
}
}
So what i am expecting that after each 20 second it should clear cache
and set new value.
After 20 seconds, the property will be re-evaluated next time the
service is requested.
However, you've got a second level of caching there - the Application
property - it's only going to be updated once with the code you've got.
Why are you caching the setter in the first place, by the way? That
seems to be pretty pointless - or worse, because it's trying to update
something rather than to fetch data.
Jon