How to implement master/slave structure with squeryl and play framework

40 views
Skip to first unread message

Anas Jaghoub

unread,
Nov 17, 2014, 8:27:28 AM11/17/14
to squ...@googlegroups.com

I am running a play framework website that uses squeryl and mysql database. I need to use squeryl to run all read queries to the slave and all write queries to the master.

How can I achieve this? either via squeryl or via jdbc connector itself.

Many thanks,

Maxime Lévesque

unread,
Nov 17, 2014, 10:59:50 AM11/17/14
to Squeryl

If you want to do it explicitely (in you code), you can have two SessionFactories (ex. slaveSessions, masterSessions),
and then transaction(slave) {...reads here..}, transaction(master) { ...writes here...}

if you want it to be handled transparently, you will have to fork and change the write methods in Table (https://github.com/squeryl/squeryl/blob/master/src/main/scala/org/squeryl/Table.scala) so that they grab
a connection from master instead of Session.currentSession.



--
You received this message because you are subscribed to the Google Groups "Squeryl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to squeryl+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages