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

Caching Objects

Hi there,

I'm writing a class which should hold some state information of my web
app. The class should be placed in the Cache for performance reasons.
But when the class gets removed from the cache (because its time has
expired), I'd like to persist the current state of the object to the
database.

Is it safe to place the code persisting the state to the db in the
destructor of the class?

Thanks in advance...
--

Kind regards!

/matthias
Nov 19 '05 #1
2 930
There are no destructors in .NET. What you're thinking about is the Finalizer.
In general the purpose of the Finalizer is to clean up any unmanaged resources
your class is holding onto. For your particular problem, I'd suggest using
the CacheItemRemoveCallback when Inserting the item into the cache. This
will notify you when the item is removed. This would be a good place to do
your persistence.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi there,

I'm writing a class which should hold some state information of my web
app. The class should be placed in the Cache for performance reasons.
But when the class gets removed from the cache (because its time has
expired), I'd like to persist the current state of the object to the
database.

Is it safe to place the code persisting the state to the db in the
destructor of the class?

Thanks in advance...

/matthias


Nov 19 '05 #2
thanks brock, I'll give it a try!

Kind regards!

/matthias

Brock Allen wrote:
There are no destructors in .NET. What you're thinking about is the
Finalizer. In general the purpose of the Finalizer is to clean up any
unmanaged resources your class is holding onto. For your particular
problem, I'd suggest using the CacheItemRemoveCallback when Inserting
the item into the cache. This will notify you when the item is removed.
This would be a good place to do your persistence.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi there,

I'm writing a class which should hold some state information of my web
app. The class should be placed in the Cache for performance reasons.
But when the class gets removed from the cache (because its time has
expired), I'd like to persist the current state of the object to the
database.

Is it safe to place the code persisting the state to the db in the
destructor of the class?

Thanks in advance...

/matthias


Nov 19 '05 #3

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

Similar topics

2
by: Marwin | last post by:
Hi all, I have a database with 40GB of binary objects stored in image columns in two tables. Our database server is also used for another 15 databases. SQL Server caches the image-column,...
15
by: olle | last post by:
Hi folks. I learning asp.net and compare it with traditional asp and Access-developing. The issue is this one: 1/I have this Ms Acceess adp-project application that works fine on my Ms Sql...
10
by: Jon Maz | last post by:
Hi, My goal is to take the entire html/javascript stream spat out by .aspx pages and save them as simple strings in a database (for caching purposes). I'm not sure how I can get hold of this...
2
by: Wee Bubba | last post by:
2 questions please: 1. At the moment I make a connection to a database whenever a user logs into my website. I run a few SQL's then store some commonly used dataTables in session objects for...
1
by: Gavin Pollock | last post by:
Is anyone using Caching (HttpRuntime.Cache) in Whidbey? Not sure if there's another newsgroup for this though since it's still beta.... I'm having issues running a system built on 1.1 in a 2.0...
4
by: DylanM | last post by:
I've seen a few examples on how to cache data in a WinForms GUI, just after some thought on the best solution. The data I'm trying to cache will be generally be small collections of Business...
2
by: Joel Barsotti | last post by:
My website has different products and I've developed a nice little object oreinted class library for them. I then use the objects for products and such on many different pages. Especially with...
2
by: thedotnetarchitect | last post by:
To keep the background simple here is my problem, I have two web servers in a web farm I would like to have a centralized caching system on another server, where I can add and remove items from...
3
by: Gary W. Smith | last post by:
I had a couple questions about data caching. We have a site that gets a huge amount of traffic to a few specific pages that have a lot of data on them (300k hits/hour during peak, about 6-10 data...
4
by: Girish | last post by:
i have to implement caching in my application, can any one tell me about the good techniques to implement caching, or provide some architectural help , so i can use it to my application. i want...
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
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)...
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....
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.