Caching and transaction, uncorrectly work together...

16 views
Skip to first unread message

François Leblanc

unread,
Sep 28, 2015, 3:52:39 AM9/28/15
to redbeanphp

I've a problem,

I've put database in SERIALIZABLE mode to avoid mistake when reading records, but redbean's caching get me in trouble,

I use to start transaction, read record do the job and save record, even if I've already read the record I read it again in

transaction if I need to change it, particulary if I need to make operations on datas (+,-,* etc) . This way since I am in

in transaction I'm sure that all operation is done correctly.

But with redbean caching if I've already read the record, when I read it again in transaction the query is not run (it's

the goal of caching) so the record is not locked in database when I do the transaction, this can produce incoherence

in database.

To prevent I have put useWriterCache to false, but this reduce performances.

I think the best will be to clear cache at the begin of a transaction, so futher reading will lock records on database.

Does it possible to clear cache queries ? Can we call a function at each begin transaction ?





gabor

unread,
Sep 28, 2015, 3:48:00 PM9/28/15
to redbeanphp


You can flush the Writer cache like this:

R
::getWriter()->flushCache();
Reply all
Reply to author
Forward
0 new messages