This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Sun Aug 23 11:23:10 -0700 2009 | |
| |
LICENSE | Fri Jun 12 08:05:53 -0700 2009 | |
| |
README | Sun Nov 08 17:59:56 -0800 2009 | |
| |
init.rb | Fri Jun 12 08:05:53 -0700 2009 | |
| |
lib/ | Sun Nov 08 17:59:56 -0800 2009 | |
| |
specs/ | Sun Aug 23 11:23:10 -0700 2009 |
README
master_slave_adapter - maurĂcio DOT linhares AT gmail DOT com
====
This simple plugin acts as a common ActiveRecord adapter and allows you to
setup a master-slave environment using any database you like (and is supported
by ActiveRecord).
This plugin works by handling two connections, one to a master database,
that will receive all non-"SELECT" statements, and another to a slave database
that that is going to receive all SELECT statements. It also tries to do as
little black magic as possible, it works just like any other ActiveRecord database
adapter and performs no monkeypatching at all, so it's easy and simple to use
and understand.
The master database connection will also receive SELECT calls if a transaction
is active at the moment or if a command is executed inside a "with_master" block:
ActiveRecord::Base.with_master do # :with_master instructs the adapter
@users = User.all # to use the master connection inside the block
end
To use this adapter you just have to install the plugin:
ruby script/plugin install git://github.com/mauricio/master_slave_adapter.git
And then configure it at your database.yml file:
development:
database: sample_development
username: root
adapter: master_slave # the adapter must be set to "master_slave"
host: 10.21.34.80
master_slave_adapter: mysql # here's where you'll place the real database adapter name
disable_connection_test: true # this will disable the connection test before use,
# can possibly improve the performance but you could also
# hit stale connections, default is false
eager_load_connections: true # connections are lazy loaded by default, you can load gem eagerly setting this to
true
master: # and here's where you'll add the master database configuration
database: talkies_development # you shouldn't specify an "adapter" here, the
username: root # value at "master_slave_adapter" is going to be used
host: 10.21.34.82
adapter: postgresql # you can use another adapter for the master connection if needed
# if you don't set it the "master_slave_adapter" property will be used






