• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/Class/DBI/H02-Jul-2001-228150

t/H02-Jul-2001-6953

ChangesH A D01-Jul-2001136 63

MANIFESTH A D02-Jul-200184 76

Makefile.PLH A D02-Jul-2001638 2818

READMEH A D02-Jul-20012.3 KiB7653

README

1NAME
2    Class::DBI::Replication - Class::DBI for replicated database
3
4SYNOPSIS
5      package Film;
6      use base qw(Class::DBI::Replication);
7
8      Film->set_master('dbi:mysql:host=master', $user, $pw);
9      Film->set_slaves(
10          [ 'dbi:mysql:host=slave1', $user, $pw ],
11          [ 'dbi:mysql:host=slave2', $user, $pw ],
12      );
13
14DESCRIPTION
15    Classs::DBI::Replication extends Class::DBI's persistence for replicated
16    databases.
17
18    The idea is very simple. SELECT from slaves, INSERT/UPDATE/DELETE to
19    master.
20
21    From http://www.mysql.com/doc/R/e/Replication_FAQ.html,
22
23      Q: What should I do to prepare my client code to use
24      performance-enhancing replication?
25
26      A: If the part of your code that is responsible for database access
27      has been properly abstracted/modularized, converting it to run with
28      the replicated setup should be very smooth and easy - just change
29      the implementation of your database access to read from some slave
30      or the master, and to always write to the master.
31
32    With Class::DBI::Replication, it can be done easily!
33
34METHODS
35    set_master
36          Film->set_master($datasource, $user, $password, \%attr);
37
38        This spcifies your master database. INSERT/UPDATE/DELETE are done
39        only to this database. Some SELECT queries also done to master for
40        concurrency problem.
41
42        If you don't want master to be distinct from slaves in SELECT
43        queries, put master in slaves, too.
44
45    set_slaves
46          Film->set_slaves(
47               [ 'dbi:mysql:host=slave1', $user, $password, \%attr ],
48               [ 'dbi:mysql:host=slave2', $user, $password, \%attr ],
49          );
50
51        This specifies your slave databases. SELECT are done to these
52        databases randomly. If you don't specify slaves, all queries are
53        gone to master, as always.
54
55TODO
56    *   More docs
57
58    *   More testing
59
60    *   retrieve() adter create() problem. Currently, SELECT calls inside
61        Class::DBI are done to master database.
62
63    *   Concurrency problems
64
65    *   Customizable slave picking algorithm like Round-Robin
66
67AUTHOR
68    Tatsuhiko Miyagawa <miyagawa@bulknews.net>
69
70    This library is free software; you can redistribute it and/or modify it
71    under the same terms as Perl itself.
72
73SEE ALSO
74    the Class::DBI manpage, the Class::DBI::mysql manpage
75
76