Skip to content

minhnghivn/my_replication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 © 2011 Nghi Pham, released under the MIT license

About

Replication support for MySQL database adapter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages