write-behind on two caches in transaction

classic Classic list List threaded Threaded
2 messages Options
Shaomin Zhang Shaomin Zhang
Reply | Threaded
Open this post in threaded view
|

write-behind on two caches in transaction

Hi

 

I have two caches: order and trade where one order entry linked to multiple trade entries and need to persist the two caches into their database tables using write-behind in transactions.

 

I don’t think that simply configuring the two cache to be write-behind enabled will work as they will be out of synchronization. Am I right?

 

What I am planning to do is to configure the master cache, order, to be write-behind and this cache will write the order and the related trades into database when a write is triggered. Is this ok? Any better design?

 

Thanks

 

Shaomin

_________________________________________________________

This email, its contents, and any attachments transmitted with it are intended only for the addressee(s) and may be confidential and legally privileged. We do not waive any confidentiality by misdelivery. If you have received this email in error, please notify the sender immediately and delete it. You should not copy it, forward it or otherwise use the contents, attachments or information in any way. Any liability for viruses is excluded to the fullest extent permitted by law.

Tudor Capital Europe LLP (TCE) is authorised and regulated by The Financial Conduct Authority (the FCA). TCE is registered as a limited liability partnership in England and Wales No: OC340673 with its registered office at 10 New Burlington Street, London, W1S 3BE, United Kingdom

vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: write-behind on two caches in transaction

Hi Shaomin,

With write-behind cache it's impossible to enlist several DB updates in one transaction, because DB is updated asynchronously and potentially from different nodes. However, this is possible if you use write-through, in this mode you can ensure transactional consistency between cache and DB.

Your approach confuses me. Are you updating trades in cache as well? How does the store knows the set of trades to write to DB?

-Val