Skip to content
Replication support for MySQL database adapter
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
MIT-LICENSE
README
README.rdoc
Rakefile
demo.rb
init.rb
install.rb
uninstall.rb

README.rdoc

Introduction

MyReplication is an extention of the existing rails' mysql database adapter that is designed to help applications switch connection to another database server in a replication database system.

Installation

rails plugin install git@github.com:minhnghivn/my_replication.git

Configuration

You need to specify a master database along with replicated ones in database.yml. For example:

development:
  adapter: mysql
  database: masterdb
  pool: 5
  username: minhnghivn
  password: secret
  host: localhost
  replicas:
    - name: replica1
      database: db1
      username: minhnghivn
      password: secret
      host: localhost
    - name: replica2
      database: db2
      username: minhnghivn
      password: secret
      host: localhost

Examples

Use “replication” block to allow switching connection (randomly) to one of the replicated databases (rather than the master one) then executing the statement inside the block

User.replication do   
  list = User.all
end

You can also explicitly specify the database connection with “using” block

User.using(:replica1) do
  list = User.all
end

Contact

Copyright

Copyright © 2011 Nghi Pham, released under the MIT license

Something went wrong with that request. Please try again.