[Dbix-class] DBIx::Class::Storage::Replication -- stick to master flag

Bill Moseley moseley at hank.org
Wed Jan 6 19:55:13 GMT 2010


On Wed, Jan 6, 2010 at 7:04 AM, John Napiorkowski <jjn1056 at yahoo.com> wrote:

>
>
> There's a few ways to force master read/write mode.  For example, anything
> inside a transaction will automatically send read traffic to the master.
>  For me I find that's enough for nearly all the master read use cases.  Y=
ou
> can always add a 'flag' as well:
>
>
> my $row =3D $resultset->search(undef, {force_pool=3D>'master'})->find($pk=
);
>
> That's what I was thinking regarding ::RestrictedWithObject, although mig=
ht
> feel like a big hammer to you.  You could
> probably also add that to the default resultset attributes of a resultset
> subclass
>

I think I'm not explaining this correctly -- or I'm missing what you are
suggesting.  Forcing reads to the master with DBIC is not the problem.

What I'm trying to do is hook into the Replication module in a way that I
can set a flag in memcached when the Replication module decides to go to the
master.

The module allows you to configure a master an a set of slaves, and then it
automatically sends reads to the slaves and writes to the master.  That's
perfect.  But, what I need is a way to set a flag when it automatically goes
to the master.

The reason is I have a separate legacy application using the same database
that does not use DBIC.  But, it needs to know when it also should read from
the master instead of slaves (for some given user/account).

So, when the DBIC app does a write I need to set a flag in memcached (keyed
by an account or user id).  Then the legacy application can check for that
flag and decide if reads should be directed to the master, too.


So, I need a way to pass in the key (and a cache object) at the start of
each request -- the key is to set in memcached *if* any writes happen -- and
a way to hook in the the Replicated module so that when it does go to the
master that flag is set in memcached.




-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20100106/9a1=
f090e/attachment.htm


More information about the DBIx-Class mailing list