Skip to content

Commit

Permalink
fix readme formatting, grrr!
Browse files Browse the repository at this point in the history
  • Loading branch information
igrigorik committed Feb 16, 2010
1 parent 9229938 commit 56c9971
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions README.md
Expand Up @@ -5,35 +5,36 @@ callbacks, errbacks and all other niceties of EventMachine while keeping the API
of the original MySQL gem. Simple, but it works. of the original MySQL gem. Simple, but it works.


Features: Features:
* Maintains mysql gem API
* Deferrables for every query with callback & errback * Maintains mysql gem API
* Connection query queue - pile 'em up! * Deferrables for every query with callback & errback
* Auto-reconnect on disconnects * Connection query queue - pile 'em up!
* Auto-retry on deadlocks * Auto-reconnect on disconnects
* Auto-retry on deadlocks


## Example usage: ## Example usage:


EventMachine.run { EventMachine.run {
conn = EventMachine::MySQL.new(:host => 'localhost') conn = EventMachine::MySQL.new(:host => 'localhost')
query = conn.query("select 1+1") query = conn.query("select 1+1")
query.callback { |res| p res.all_hashes } query.callback { |res| p res.all_hashes }
query.errback { |res| p res.all_hashes } query.errback { |res| p res.all_hashes }
} }


## Query queueing: ## Query queueing:


EventMachine.run { EventMachine.run {
conn = EventMachine::MySQL.new(:host => 'localhost') conn = EventMachine::MySQL.new(:host => 'localhost')


results = [] results = []
conn.query("select 1") {|res| results.push res.fetch_row.first.to_i} 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 2") {|res| results.push res.fetch_row.first.to_i}
conn.query("select 3") {|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) { EventMachine.add_timer(0.05) {
p results # => [1,2,3] p results # => [1,2,3]
} }
} }


# Credits # Credits


Expand Down

0 comments on commit 56c9971

Please sign in to comment.