Update cache object

H

hharry

Hello All,

I save a Hashtable of stock symbols + prices to the cache. The prices
are updated every 30 minutes and saved to a database table.

I would like to always have the latest prices in the cache...is there
a way to dynamically update a cache object ?


Pointers appreciated
Thanks
 
M

Mike

Do you want the latest price prior to saving to the database or the price
from the database?
 
G

Guest

The basic pattern is as follows (pseudo-code):

1) get the "Stuff" - from the web, wherever
2) Store it in Cache with a timed expiration
3) Store it in the database if you want

Your "GetMyStuff" method will:
1) check if the cache item is null
2) if so, get the Stuff and update the Cache item
3) if not null, just get it right out of the Cache

This can all be done inside a single "getMyStuff" method so that the caching
part
is opaque to the user/ caller.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,177
Latest member
OrderGlucea
Top