mslinn / quill-cache

Caching layer overtop Quill for Scala
25 stars 2 forks source link

Transaction support #4

Closed marmeblade closed 6 years ago

marmeblade commented 6 years ago

From what I gathered I reckon quill-cache does not support transactions, right? This, for me, is not that big of a deal, because I mainly want to use it for read-intensive config data in my application. A possible problem however are many-to-many relations, where my forms will update an object, as well as relations to another entity with join-tables. Say for example users and group relations. Now if a user-group insert fails, I naturally want to rollback the already updated user as well. Does anyone have an idea how to deal with that in quill-cache?

mslinn commented 6 years ago

Read-mostly tables would not normally be used for transactions.

marmeblade commented 6 years ago

Correct, but sometimes I have to write to the database and then the entity is inserted into the cache. So for my example I would need to manually delete or unupdate the entity (update it to its former state), right? This is of course possible, but might be problematic with database-set fields, like an update timestamp.

mslinn commented 6 years ago

Does not sound like your use case maps well to quill-cache's intended use for read-mostly tables, which in general remain unchanged over multiple restarts of the application. However, if you have some tables that are more permanent than others, the more static tables might match up with quill-cache's read-mostly usage pattern.

A second possibility could be to flesh out quill-cache's half-baked support for more dynamic tables, characterized by a mixing in a soft cache. This would accommodate data that changes more frequently. As you point out, the infrastructure to do this would need to accommodate more complex usage patterns. The danger of being tempted to re-invent something Hibernate exists.

marmeblade commented 6 years ago

I see your point now, although for me the read-mostly still applies and I'm just bound to use transactions for entities with Many-To-Many relationships, as these affect multiple tables at once. I agree adding something like that to quill-cache would complicate a lot of things. I will try to solve my problem in another way. Thanks for your help! I will close this issue then.