Permalink
Browse files

update readme to point to mysql2 + em-synchrony

1 parent 3532056 commit 11d6e1123654b948c1d0a8c9d9077e82420b2846 @igrigorik committed Aug 27, 2011
Showing with 25 additions and 23 deletions.
  1. +25 −23 README.md
View
@@ -1,10 +1,8 @@
# EM-MySQL (Plus)
-**Note**: [mysql2 gem](https://github.com/brianmario/mysql2) now ships with an Eventmachine driver - I recommend you switch/use that!
+**[mysql2 gem](https://github.com/brianmario/mysql2) now ships with an EM driver - I recommend you switch & use it! And if you want synchronous API but an async driver, then take a look at [em-synchrony](https://github.com/igrigorik/em-synchrony)**
-EventMachine wrapper for the C-based MySQL / MySQLPlus Ruby gems, which provides
-callbacks, errbacks and all other niceties of EventMachine while keeping the API
-of the original C-based MySQL gem.
+EventMachine wrapper for the C-based MySQL / MySQLPlus Ruby gems, which provides callbacks, errbacks and all other niceties of EventMachine while keeping the API of the original C-based MySQL gem.
Features:
@@ -15,30 +13,34 @@ Features:
* Auto-retry on deadlocks
## Example usage:
- > gem install em-mysqlplus
- > irb -r em-mysqlplus
-
- EventMachine.run {
- conn = EventMachine::MySQL.new(:host => 'localhost')
- query = conn.query("select 1+1")
- query.callback { |res| p res.all_hashes }
- query.errback { |res| p res.all_hashes }
- }
+```ruby
+# gem install em-mysqlplus
+# irb -r em-mysqlplus
+
+EventMachine.run do
+ conn = EventMachine::MySQL.new(:host => 'localhost')
+ query = conn.query("select 1+1")
+ query.callback { |res| p res.all_hashes }
+ query.errback { |res| p res.all_hashes }
+end
+```
## Query queueing:
- EventMachine.run {
- conn = EventMachine::MySQL.new(:host => 'localhost')
+```ruby
+EventMachine.run do
+ conn = EventMachine::MySQL.new(:host => 'localhost')
- results = []
- conn.query("select 1") {|res| results.push res.fetch_row.first.to_i}
- conn.query("select 2") {|res| results.push res.fetch_row.first.to_i}
- conn.query("select 3") {|res| results.push res.fetch_row.first.to_i}
+ results = []
+ conn.query("select 1") {|res| results.push res.fetch_row.first.to_i}
+ conn.query("select 2") {|res| results.push res.fetch_row.first.to_i}
+ conn.query("select 3") {|res| results.push res.fetch_row.first.to_i}
- EventMachine.add_timer(0.05) {
- p results # => [1,2,3]
- }
- }
+ EventMachine.add_timer(0.05) do
+ p results # => [1,2,3]
+ end
+end
+```
# Credits

0 comments on commit 11d6e11

Please sign in to comment.