GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  CLASS::DBI::REPLICATION (3)

.ds Aq ’

NAME

Class::DBI::Replication - Class::DBI for replicated database

CONTENTS

SYNOPSIS



  package Film;
  use base qw(Class::DBI::Replication);
   
  Film->set_master(dbi:mysql:host=master, $user, $pw);
  Film->set_slaves(
      [ dbi:mysql:host=slave1, $user, $pw ],
      [ dbi:mysql:host=slave2, $user, $pw ],
  );



DESCRIPTION

Classs::DBI::Replication extends Class::DBI’s persistence for replicated databases.

The idea is very simple. SELECT from slaves, INSERT/UPDATE/DELETE to master.

From http://www.mysql.com/doc/R/e/Replication_FAQ.html,



  Q: What should I do to prepare my client code to use
  performance-enhancing replication?

  A: If the part of your code that is responsible for database access
  has been properly abstracted/modularized, converting it to run with
  the replicated setup should be very smooth and easy - just change
  the implementation of your database access to read from some slave
  or the master, and to always write to the master.



With Class::DBI::Replication, it can be done easily!

METHODS

set_master


  Film->set_master($datasource, $user, $password, \%attr);



This spcifies your master database. INSERT/UPDATE/DELETE are done only to this database. Some SELECT queries also done to master for concurrency problem.

If you don’t want master to be distinct from slaves in SELECT queries, put master in slaves, too.

set_slaves


  Film->set_slaves(
       [ dbi:mysql:host=slave1, $user, $password, \%attr ],
       [ dbi:mysql:host=slave2, $user, $password, \%attr ],
  );



This specifies your slave databases. SELECT are done to these databases randomly. If you don’t specify slaves, all queries are gone to master, as always.

TODO

o More docs
o More testing
o retrieve() adter create() problem. Currently, SELECT calls inside Class::DBI are done to master database.
o Concurrency problems
o Customizable slave picking algorithm like Round-Robin

AUTHOR

Tatsuhiko Miyagawa <miyagawa@bulknews.net>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Class::DBI, Class::DBI::mysql
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 CLASS::DBI::REPLICATION (3) 2001-07-02

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.