473,320 Members | 1,982 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,320 software developers and data experts.

Cache Policy Advice

I attempted to post this yesterday however I dont see that
it ever made it up. If this is an error on my part, I
apologize in advance.

I've got a webapp with somewhat trivial amount of data,
however aquiring the data from the database usually takes
approximately 1.5minutes. So first thing that pops into my
head is cache it.

What I'd like to do is load the cache up on
Application_Start, then refresh every 4hrs or so. I'd like
to avoid handling it lazily, because that guarentees one
person will need to wait 1.5 minutes, whereas if it was
just refreshed every 4hrs on the backend, that condition
may occur, and it may not.

I've got no problem loading up data on application_start,
and set a CacheItemRemovedCallBack to execute a method to
reload the cache with the data. The problem I am
encountering is that I cant get a HttpContext to pull the
cache object from.

Should I be doing this a better way, or anyone have any
sort of advice whatsoever? Source samples?

Thanks in advance,
Weston Weems
Nov 19 '05 #1
5 1173
Weston,

Where exactly in the code are you having a problem with retrieving the
HttpContext instance?

:DG<

"Weston Weems" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
I attempted to post this yesterday however I dont see that
it ever made it up. If this is an error on my part, I
apologize in advance.

I've got a webapp with somewhat trivial amount of data,
however aquiring the data from the database usually takes
approximately 1.5minutes. So first thing that pops into my
head is cache it.

What I'd like to do is load the cache up on
Application_Start, then refresh every 4hrs or so. I'd like
to avoid handling it lazily, because that guarentees one
person will need to wait 1.5 minutes, whereas if it was
just refreshed every 4hrs on the backend, that condition
may occur, and it may not.

I've got no problem loading up data on application_start,
and set a CacheItemRemovedCallBack to execute a method to
reload the cache with the data. The problem I am
encountering is that I cant get a HttpContext to pull the
cache object from.

Should I be doing this a better way, or anyone have any
sort of advice whatsoever? Source samples?

Thanks in advance,
Weston Weems

Nov 19 '05 #2
Use System.Web.HttpRuntime.Cache. This static property of the Application
class returns the Cache.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Weston Weems" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
I attempted to post this yesterday however I dont see that
it ever made it up. If this is an error on my part, I
apologize in advance.

I've got a webapp with somewhat trivial amount of data,
however aquiring the data from the database usually takes
approximately 1.5minutes. So first thing that pops into my
head is cache it.

What I'd like to do is load the cache up on
Application_Start, then refresh every 4hrs or so. I'd like
to avoid handling it lazily, because that guarentees one
person will need to wait 1.5 minutes, whereas if it was
just refreshed every 4hrs on the backend, that condition
may occur, and it may not.

I've got no problem loading up data on application_start,
and set a CacheItemRemovedCallBack to execute a method to
reload the cache with the data. The problem I am
encountering is that I cant get a HttpContext to pull the
cache object from.

Should I be doing this a better way, or anyone have any
sort of advice whatsoever? Source samples?

Thanks in advance,
Weston Weems

Nov 19 '05 #3
I've set up

MyNamespace.Caching - as a simple class that contains a
few methods to set/purge cache items, as well as
containing CacheItemRemovedCallBack.

I do MyCache.Caching.AddCacheItem(object item)

which will insert with a expriation of now+4hrs, and a
CacheItemRemovedCallBack which is also in my Caching
namespace.

The problem is it loads initially, but when it goes to
refresh, it gives me a null reference exception for some
strange reason.

If I've got the wrong idea, does anyone have examples of
how one might achieve this?

thank you very much.
Weston Weems



-----Original Message-----
Weston,

Where exactly in the code are you having a problem with retrieving theHttpContext instance?

:DG<

"Weston Weems" <an*******@discussions.microsoft.com> wrote in messagenews:04****************************@phx.gbl...
I attempted to post this yesterday however I dont see that it ever made it up. If this is an error on my part, I
apologize in advance.

I've got a webapp with somewhat trivial amount of data,
however aquiring the data from the database usually takes approximately 1.5minutes. So first thing that pops into my head is cache it.

What I'd like to do is load the cache up on
Application_Start, then refresh every 4hrs or so. I'd like to avoid handling it lazily, because that guarentees one
person will need to wait 1.5 minutes, whereas if it was
just refreshed every 4hrs on the backend, that condition
may occur, and it may not.

I've got no problem loading up data on application_start, and set a CacheItemRemovedCallBack to execute a method to reload the cache with the data. The problem I am
encountering is that I cant get a HttpContext to pull the cache object from.

Should I be doing this a better way, or anyone have any
sort of advice whatsoever? Source samples?

Thanks in advance,
Weston Weems

.

Nov 19 '05 #4
Thank you this was exactly the sort of thing I was looking
for.
I'll give it a whirl.
-----Original Message-----
Use System.Web.HttpRuntime.Cache. This static property of the Applicationclass returns the Cache.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Weston Weems" <an*******@discussions.microsoft.com> wrote in messagenews:04****************************@phx.gbl...
I attempted to post this yesterday however I dont see that it ever made it up. If this is an error on my part, I
apologize in advance.

I've got a webapp with somewhat trivial amount of data,
however aquiring the data from the database usually takes approximately 1.5minutes. So first thing that pops into my head is cache it.

What I'd like to do is load the cache up on
Application_Start, then refresh every 4hrs or so. I'd like to avoid handling it lazily, because that guarentees one
person will need to wait 1.5 minutes, whereas if it was
just refreshed every 4hrs on the backend, that condition
may occur, and it may not.

I've got no problem loading up data on application_start, and set a CacheItemRemovedCallBack to execute a method to reload the cache with the data. The problem I am
encountering is that I cant get a HttpContext to pull the cache object from.

Should I be doing this a better way, or anyone have any
sort of advice whatsoever? Source samples?

Thanks in advance,
Weston Weems

.

Nov 19 '05 #5
Thank you, that worked perfectly!
Weston

-----Original Message-----
Use System.Web.HttpRuntime.Cache. This static property of the Applicationclass returns the Cache.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Weston Weems" <an*******@discussions.microsoft.com> wrote in messagenews:04****************************@phx.gbl...
I attempted to post this yesterday however I dont see that it ever made it up. If this is an error on my part, I
apologize in advance.

I've got a webapp with somewhat trivial amount of data,
however aquiring the data from the database usually takes approximately 1.5minutes. So first thing that pops into my head is cache it.

What I'd like to do is load the cache up on
Application_Start, then refresh every 4hrs or so. I'd like to avoid handling it lazily, because that guarentees one
person will need to wait 1.5 minutes, whereas if it was
just refreshed every 4hrs on the backend, that condition
may occur, and it may not.

I've got no problem loading up data on application_start, and set a CacheItemRemovedCallBack to execute a method to reload the cache with the data. The problem I am
encountering is that I cant get a HttpContext to pull the cache object from.

Should I be doing this a better way, or anyone have any
sort of advice whatsoever? Source samples?

Thanks in advance,
Weston Weems

.

Nov 19 '05 #6

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

Similar topics

1
by: Angela | last post by:
This question is in reference to another question I posted titled, "This advertised application will not be installed because it might be unsafe". The error I am getting says I need to change...
10
by: Simon Wallis | last post by:
I know the general purpose for the GAC is to share a component among many applications. But even when you add something to the GAC, you still have to manually create a reference to the DLL in your...
2
by: Showjumper | last post by:
If i use the cache class in the global asax file in the session sub, can i override for an individual page that has content that will be changing more frequently than the rest of the site? Would i...
1
by: Joe Fallon | last post by:
I am trying to setup a cache that refreshes itself every hour. (My sample code is for every minute so I can test it.) I have found some examples that I thought worked but they all seem to fail....
2
by: George Durzi | last post by:
I have a dll that I use in several projects, that I placed in the Global Assembly Cache. This dll is references in each of my projects. This Dll is referenced by a type= declaration in my...
6
by: Charts | last post by:
I used HttpContext.Current.Cache To cache data from database. The code is like that. public static DataView GetCategories() { if ( HttpContext.Current.Cache == null ) {...
26
by: Ed L. | last post by:
Here's some of my current notions on pgsql performance tuning strictly as it relates to pgsql tuning parameters in the context of a dedicated linux or hpux server. I'm particularly focusing on...
5
by: Stan SR | last post by:
Hi, Some newbie questions.. :-) First, what is the namespace to use for the Cache class ? When I use this bit of code I get an error if (Cache==null) Cache.Insert("myUserList",userlist);...
0
by: almurph | last post by:
Hi, Hope you can help me with this one. When the asp.net cache reaches maximum capacity the object are removed automatically by the system using a least recently used policy (cf....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
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...
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...
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)...
0
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...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.