A plugin solves the "persistency problem" in RoR ...partially.

My observation about ruby and transactions, started an interesting discussion (see also Funny reaction in RoR space to comment about transactions, The cure for RoR Active Record and transactions). The problem here: in RoR multiple instances of a persistent object with the same PK can exist in the SAME transaction, which can lead to inconsistencies, or you have to deal with optimistic concurrency INSIDE a transaction (which is funny).

As a reaction, Simon Harris provided an implementation of a RoR plugin with the IdentityMap implementation, which solves the problem of stale objects. The implementation is lean, and can be provided, without changing the RoR frameworks (which speaks for extendibility of RoR).

IdentityMap only solves the problem, in case you are only working with the instances inside a transaction. You should not access/change the database directly, because then your transactional cache (the identity map) would become inconsistent. If you like also to work with the database, a robust invalidation mechanism is needed.

In case you have already an IdentityMap, why you would like to invoke save()? Wouldn't it be cleaner to store automatically all contents of the IdentityMap at the end of transaction automatically?

NEW: Online Workhop Effective WebApps without Frameworks is also coming to: MUC Airport.

Airport MUC workshops: Web (SPA, PWAs, Offline, Desktop, Mobile) Applications Essentials and Effective Web Applications. No migrations. #usetheplatform

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns


Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments