473,326 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Periodically Refreshing Cache Data

I have a web service that I am putting together that queries a database and
some of the queries take a fair bit of time. I want to cache the data,
which I can easily do using the Application object, but I want it to refresh
itself periodically.

The trick is, that I DON'T want the evaluation of the cach object expiring
done at the time the client makes the query and then upon discovery that the
cache has expired, it refreshes the data. Which is how the CacheDuration
operates.

What I want to be done is that the data is queried and cached in the
background every xx minutes regardless if a client is accessing that method
or not, so that the client never sees the query delay.

Any ideas as to the best method?
Jul 4 '07 #1
4 2244
"blackhawk" <bl*******@discussions.microsoft.comwrote in message
news:5A**********************************@microsof t.com...
>I have a web service that I am putting together that queries a database and
some of the queries take a fair bit of time. I want to cache the data,
which I can easily do using the Application object, but I want it to
refresh
itself periodically.

The trick is, that I DON'T want the evaluation of the cach object expiring
done at the time the client makes the query and then upon discovery that
the
cache has expired, it refreshes the data. Which is how the CacheDuration
operates.

What I want to be done is that the data is queried and cached in the
background every xx minutes regardless if a client is accessing that
method
or not, so that the client never sees the query delay.

Any ideas as to the best method?
With .NET 2.0, you can use the Cache object with a timed expiration and a
callback method.

You may want to look at Caching Architecture Guide for .NET Framework
Applications, at http://msdn2.microsoft.com/en-us/library/ms978500.aspx.
--
John Saunders [MVP]

Jul 4 '07 #2
John,

Perhaps I am not doing it correctly, but when the client calls the
webservice, the cache object's lifetime is only during that one session.

I need this to exist indefinitely and across client sessions.

If this can be done, do you have some sample code I can use to model from?
"John Saunders [MVP]" wrote:
"blackhawk" <bl*******@discussions.microsoft.comwrote in message
news:5A**********************************@microsof t.com...
I have a web service that I am putting together that queries a database and
some of the queries take a fair bit of time. I want to cache the data,
which I can easily do using the Application object, but I want it to
refresh
itself periodically.

The trick is, that I DON'T want the evaluation of the cach object expiring
done at the time the client makes the query and then upon discovery that
the
cache has expired, it refreshes the data. Which is how the CacheDuration
operates.

What I want to be done is that the data is queried and cached in the
background every xx minutes regardless if a client is accessing that
method
or not, so that the client never sees the query delay.

Any ideas as to the best method?

With .NET 2.0, you can use the Cache object with a timed expiration and a
callback method.

You may want to look at Caching Architecture Guide for .NET Framework
Applications, at http://msdn2.microsoft.com/en-us/library/ms978500.aspx.
--
John Saunders [MVP]

Jul 4 '07 #3
"blackhawk" <bl*******@discussions.microsoft.comwrote in message
news:A0**********************************@microsof t.com...
John,

Perhaps I am not doing it correctly, but when the client calls the
webservice, the cache object's lifetime is only during that one session.

I need this to exist indefinitely and across client sessions.

If this can be done, do you have some sample code I can use to model from?
Cache persists for the duration of the AppDomain. It's more than just
per-session.
--
John Saunders [MVP]

Jul 4 '07 #4
John,

Well, I ended up creating my own cache controller and cache item object
which spawns off a thread upon creating the cache controller object. This
controller object then spools through the cache items and figures out when to
re-run them periodically to refresh the data.

The only concern that I had in doing this approach was to make sure that IIS
did not unload the webservice periodically and kill the thread. Seems, so
far to be working on XP, but haven't tried it on Server 2003.
"John Saunders [MVP]" wrote:
"blackhawk" <bl*******@discussions.microsoft.comwrote in message
news:A0**********************************@microsof t.com...
John,

Perhaps I am not doing it correctly, but when the client calls the
webservice, the cache object's lifetime is only during that one session.

I need this to exist indefinitely and across client sessions.

If this can be done, do you have some sample code I can use to model from?

Cache persists for the duration of the AppDomain. It's more than just
per-session.
--
John Saunders [MVP]

Jul 6 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bill | last post by:
I have a page that scrolls out information from a database. When one of the records has been completed by the user, they press delete at the end of the row, and it sends the record id to a...
6
by: Ken | last post by:
How does IE6 control the display of images? I change the content of a image file image1.jpg without changing the file name. Then jump to a new page to display it. IE6 does not displays the...
5
by: Wayne Wengert | last post by:
I have a menu that calls a specific asp page and passes a variable data1page.asp?year=2001 where the value of the year variable is determined in code. This works fine the first 2 times I...
1
by: Mr. x | last post by:
Hello, How can I force refreshing of my web site, when a visitor enter my site. Thanks :)
2
by: jdi | last post by:
Hello, I have a seemingly basic question about ASP.NET. I would like to create a page containing an image, which keeps swapping the url of the image source, without refreshing the entire page. ...
2
by: Mr. x | last post by:
Hello, How can I force refreshing of my web site, when a visitor enter my site. Thanks :)
1
by: Oleg | last post by:
Hi, I'm having a problem with page caching and therefore reusing dropdown box contents. Scenerio: user1 has security to see list of three items(.aspx populates it with three items only) in...
6
by: Mark Denardo | last post by:
I created a Web Image "<asp:Image ID="Image1" ..." that my code behind set to a certain image file say image1.jpg =Image1.ImageUrl = "<rel_path>/image1.jpg"; which set the image ok, but then I...
3
by: gsuns82 | last post by:
Hi all, I am using modal window for some update purpose, the issue i am facing is,i am not able to refresh parent after closing modal window. The code i used: ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.