views:

111

answers:

2

I have a windows service that receives a large amount of data that needs to be transformed and persisted to a database. To ensure that we do not lose data, I want to create a "Write cache" for the data that will continue regardless if the database is online. Once the database becomes available again, I would want it to flush the content of the cache back into the database.

I've seen some articles indicating that I might be able to do this with NHibernate, but I haven't found it conclusively. What options exist for this, and is NHibernate the appropriate direction?

+1  A: 

What if the write cache goes offline? Than you need another writecache to ensure the first writecache. This is a recursive pattern of creating (fake) availability. Use a cluster of multiple machines to make the chance of unavailability as small as possible. The availability of a sql database is probably higher than any other component in your system.

I don't handle these kind of exceptions in services, I just call the service again (indirect) with it's original input when it fails for downtime of any subsystem. The original input can be your "writecache".

Paco
This is pretty much a non-answer. Assuming that the service is using the HDD of the machine it is running on as the write cache, the probability of it simultaneously failing (ie, write cache goes offline) AND the database server going offline is VERY low. Your advice is valid, indeed, but you aren't answering the question.
snicker
A: 

Dear Todd

I am agreed with Paco but still there are some scenarios like if a database is being updated too frequently then you might need to implement as you are asking for.

This is called write-behind scenario

Look at the following article

http://wiki.tangosol.com/display/COH32UG/Read-Through,+Write-Through,+Refresh-Ahead+and+Write-Behind+Caching

If you think you really need it you can use NCache server http://www.alachisoft.com/ncache/

OR there are other applications available too to handle such situation and also you can write your own application or code to ensure this.

Regards Mubashar

Mubashar Ahmad