{"id":1819,"date":"2014-12-16T17:45:47","date_gmt":"2014-12-16T17:45:47","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=1819"},"modified":"2025-06-13T23:52:01","modified_gmt":"2025-06-14T06:52:01","slug":"using-couchbase-ruby-gem-eventmachine","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/es\/using-couchbase-ruby-gem-eventmachine\/","title":{"rendered":"Uso de Couchbase Ruby Gem con EventMachine"},"content":{"rendered":"<p>As you may have noticed the new <a href=\"https:\/\/rubygems.org\/gems\/couchbase\">couchbase ruby gem<\/a> has been released recently. The release 1.2.2 is mostly a maintenance release with several bug fixes, but yet you can try one new experimental feature: integration with <a href=\"https:\/\/rubygems.org\/gems\/eventmachine\">EventMachine<\/a> library. This post will give you a quick intro about how to start using Couchbase Server with your applications based on the EventMachine asynchronous model.<\/p>\n<p>The EventMachine integration is only (currently) accessible on UNIX-like systems (like Linux, Solaris, BSD). \u00a0Because it uses fibers, it also requires MRI ruby version 1.9 or later.<\/p>\n<h2>Setup Your Sandbox<\/h2>\n<p>First step is installing the libcouchbase library which handles all of the low level Couchbase protocol details. You can follow the <a href=\"https:\/\/www.couchbase.com\/develop\/c\/current\/\">installation guide on the official page<\/a>. Here I\u2019ll only replicate steps needed for typical GNU\/Linux box (I\u2019m using Debian unstable):<\/p>\n<ol>\n<li>\n<p>Install repository PGP key:<\/p>\n<div class=\"geshifilter\">\n<div class=\"text geshifilter-text\" style=\"font-family:monospace\">$ wget -O- https:\/\/packages.couchbase.com\/ubuntu\/couchbase.key | sudo apt-key add &#8211;<\/div>\n<\/p><\/div>\n<\/li>\n<li>\n<p>Setup repository source. Here I\u2019m using the link for Ubuntu 12.04, but in general it doesn\u2019t matter because we are going to use EventMachine plugin, which built into the gem itself. The packages are in different packages repositories built using the same codebase;\u00a0the only difference is the\u00a0version\u00a0of IO libraries (<a href=\"https:\/\/libevent.org\">libevent<\/a>, <a href=\"https:\/\/software.schmorp.de\/pkg\/libev.html\">libev<\/a>) included in the version of the distribution.<\/p>\n<div class=\"geshifilter\">\n<div class=\"text geshifilter-text\" style=\"font-family:monospace\">$ sudo wget -O\/etc\/apt\/sources.list.d\/couchbase.list https:\/\/packages.couchbase.com\/ubuntu\/couchbase-ubuntu1204.list<\/div>\n<\/p><\/div>\n<\/li>\n<li>\n<p>Install libcouchbase headers, core library and debug symbols. Again, you might want to install command line tools or one of the IO backends, but that&#039;s not required for the task at hand.<\/p>\n<div class=\"geshifilter\">\n<div class=\"text geshifilter-text\" style=\"font-family:monospace\">$ sudo apt-get update<br \/>\n\t$ sudo sudo apt-get install libcouchbase-dev libcouchbase2-core libcouchbase-dbg<\/div>\n<div class=\"text geshifilter-text\" style=\"font-family:monospace\">\u00a0<\/div>\n<\/p><\/div>\n<p>That&#039;s it.\u00a0<\/p>\n<p>Now you need to install <a href=\"https:\/\/www.couchbase.com\/download\/\">Couchbase Server<\/a>, follow instructions from the official site. After installation you will get administrator console running at https:\/\/localhost:8091 and also REST API accessible on the same port. Step through initial configuration steps and eventually you will allocate bucket with the name \u201cdefault\u201d.<\/p>\n<\/li>\n<li>\n<p>Finally you need to install the gem itself. It is as easy as typing this into the terminal:<\/p>\n<div class=\"geshifilter\">\n<div class=\"text geshifilter-text\" style=\"font-family:monospace\">$ gem install couchbase<br \/>\n\tBuilding native extensions. \u00a0This could take a while&#8230;<br \/>\n\tSuccessfully installed couchbase-1.2.2<br \/>\n\t1 gem installed<br \/>\n\tInstalling ri documentation for couchbase-1.2.2&#8230;<br \/>\n\tInstalling RDoc documentation for couchbase-1.2.2&#8230;<\/div>\n<\/p><\/div>\n<\/li>\n<\/ol>\n<h2>Building the Application<\/h2>\n<p>To demonstrate the integration, lets build simple chat application using EventMachine and the add logging for all events there to a Couchbase bucket. It is extremely easy to build an asynchronous application with EventMachine and to prove it I will put the complete source in this post (also found in\u00a0<a href=\"https:\/\/github.com\/couchbase\/couchbase-ruby-client\/tree\/master\/examples\/chat-em\">examples\/chat-em<\/a> directory of the gem sources).<\/p>\n<div class=\"geshifilter\">\n<div class=\"text geshifilter-text\" style=\"font-family:monospace\">class ChatServer &lt; EM::Connection<\/p>\n<p>\u00a0 @@clients = []<\/p>\n<p>\u00a0 def post_init<br \/>\n\u00a0 \u00a0 @username = nil<br \/>\n\u00a0 \u00a0 send_data(&#8220;*** What is your name?n&#8221;)<br \/>\n\u00a0 end<\/p>\n<p>\u00a0 def receive_data(data)<br \/>\n\u00a0 \u00a0 if @username<br \/>\n\u00a0 \u00a0 \u00a0 broadcast(data.strip, @username)<br \/>\n\u00a0 \u00a0 else<br \/>\n\u00a0 \u00a0 \u00a0 name = data.gsub(\/s+|[[]]\/, &#039;&#039;).strip[0..20]<br \/>\n\u00a0 \u00a0 \u00a0 if name.empty?<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 send_data(&#8220;*** What is your name?n&#8221;)<br \/>\n\u00a0 \u00a0 \u00a0 else<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 @username = name<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 @@clients.push(self)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 broadcast(&#8220;#{@username} has joined&#8221;)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 send_data(&#8220;*** Hi, #{@username}!n&#8221;)<br \/>\n\u00a0 \u00a0 \u00a0 end<br \/>\n\u00a0 \u00a0 end<br \/>\n\u00a0 end<\/p>\n<p>\u00a0 def unbind<br \/>\n\u00a0 \u00a0 @@clients.delete(self)<br \/>\n\u00a0 \u00a0 broadcast(&#8220;#{@username} has left&#8221;) if @username<br \/>\n\u00a0 end<\/p>\n<p>\u00a0 def broadcast(message, author = nil)<br \/>\n\u00a0 \u00a0 prefix = author ? &#8220;&#8221; : &#8220;***&#8221;<br \/>\n\u00a0 \u00a0 @@clients.each do |client|<br \/>\n\u00a0 \u00a0 \u00a0 unless client == self<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 client.send_data(&#8220;#{prefix} #{message}n&#8221;)<br \/>\n\u00a0 \u00a0 \u00a0 end<br \/>\n\u00a0 \u00a0 end<br \/>\n\u00a0 end<\/p>\n<p>end<\/p>\n<p>EventMachine.run do<br \/>\n\u00a0 # hit Control + C to stop<br \/>\n\u00a0 Signal.trap(&#8220;INT&#8221;) \u00a0{ EventMachine.stop }<br \/>\n\u00a0 Signal.trap(&#8220;TERM&#8221;) { EventMachine.stop }<\/p>\n<p>\u00a0 EventMachine.start_server(&#8220;0.0.0.0&#8221;, 9999, ChatServer)<br \/>\nend<\/div>\n<\/div>\n<p>This is typical EventMachine server based on EM::Connection. For those who don\u2019t know the meaning of these redefined methods here is an excerpt from the <a href=\"https:\/\/eventmachine.rubyforge.org\/EventMachine\/Connection.html\">official documentation<\/a>:<\/p>\n<blockquote>\n<p>EventMachine::Connection is a class that is instantiated by EventMachine\u2019s processing loop whenever a new connection is created. (New connections can be either initiated locally to a remote server or accepted locally from a remote client.) When a Connection object is instantiated, it mixes in the functionality contained in the user-defined module specified in calls to connect or start_server. User-defined handler modules may redefine any or all of the standard methods defined here, as well as add arbitrary additional code that will also be mixed in.<\/p>\n<p>EventMachine manages one object inherited from EventMachine::Connection (and containing the mixed-in user code) for every network connection that is active at any given time. The event loop will automatically call methods on EventMachine::Connection objects whenever specific events occur on the corresponding connections, as described below.<\/p>\n<p>This class is never instantiated by user code, and does not publish an initialize method. The instance methods of EventMachine::Connection which may be called by the event loop are: #post_init, #connection_completed, #receive_data, #unbind, #ssl_verify_peer (if TLS is used), #ssl_handshake_completed<\/p>\n<p>All of the other instance methods defined here are called only by user code.<\/p>\n<\/blockquote>\n<p>The protocol is very simple and line oriented. For each connection EventMachine will create an instance of ChatServer, which first ask the name of new participant and then broadcast all his messages to the group. You can use your favorite tool which allow you communicate over arbitrary text protocol, like telnet for example or nc. Here is sample of session between endpoints.<\/p>\n<div class=\"geshifilter\">\n<div class=\"text geshifilter-text\" style=\"font-family:monospace\">~ $ telnet localhost 9999 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ??? ~ $ nc localhost 9999<br \/>\nTrying 127.0.0.1&#8230; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ??? *** What is your name?<br \/>\nConnected to localhost. \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ??? alice<br \/>\nEscape character is &#039;^]&#039;. \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ??? *** Hi, alice!<br \/>\n*** What is your name? \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0??? *** bob has joined<br \/>\nbob \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ???  hi everyone<br \/>\n*** Hi, bob! \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0??? hello, bob! how are you?<br \/>\nhi everyone \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ??? ^C<br \/>\n hello, bob! how are you? \u00a0 \u00a0??? ~ $<br \/>\n*** alice has left \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0???<br \/>\n^] \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0???<br \/>\ntelnet&gt; Connection closed. \u00a0 \u00a0 \u00a0 \u00a0 \u00a0???<br \/>\n~ $ \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ???<\/div>\n<\/div>\n<p>Now it&#039;s time to add a bit of Couchbase. Imagine I\u2019d like to keep all messages in a distributed database as efficiently as I can. <a href=\"https:\/\/www.couchbase.com\/why-nosql\/nosql-database\/\">Couchbase is the answer<\/a> :). To do so I need to:<\/p>\n<p>Implement a log method in the ChatServer class, which should accept the message and an optional author (for system events it will be nil):<\/p>\n<div class=\"geshifilter\">\n<div class=\"text geshifilter-text\" style=\"font-family:monospace\">def log(message, author = nil)<br \/>\n\u00a0 Couchbase.bucket.incr(&#8220;log:key&#8221;, :initial =&gt; 1) do |res|<br \/>\n\u00a0 \u00a0 entry = {<br \/>\n\u00a0 \u00a0 \u00a0 &#039;time&#039; =&gt; Time.now.utc,<br \/>\n\u00a0 \u00a0 \u00a0 &#039;author&#039; =&gt; author || &#8220;[system]&#8221;,<br \/>\n\u00a0 \u00a0 \u00a0 &#039;message&#039; =&gt; message<br \/>\n\u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0 Couchbase.bucket.set(&#8220;log:#{res.value}&#8221;, entry)<br \/>\n\u00a0 end<br \/>\nend<\/div>\n<\/div>\n<p>Then I add a call to log(message, author) in the broadcast method just before iterating all connected clients. And wrap EventMachine.start_server with Couchbase::Bucket#on_connect callback, to execute the server just after the client has been connected. The resulting loop execution will look like this:<\/p>\n<div class=\"geshifilter\">\n<div class=\"text geshifilter-text\" style=\"font-family:monospace\">EventMachine.run do<br \/>\n\u00a0 # hit Control + C to stop<br \/>\n\u00a0 Signal.trap(&#8220;INT&#8221;) \u00a0{ EventMachine.stop }<br \/>\n\u00a0 Signal.trap(&#8220;TERM&#8221;) { EventMachine.stop }<\/p>\n<p>\u00a0 Couchbase.connection_options = {:async =&gt; true, :engine =&gt; :eventmachine}<br \/>\n\u00a0 Couchbase.bucket.on_connect do |res|<br \/>\n\u00a0 \u00a0 if res.success?<br \/>\n\u00a0 \u00a0 \u00a0 EventMachine.start_server(&#8220;0.0.0.0&#8221;, 9999, ChatServer)<br \/>\n\u00a0 \u00a0 else<br \/>\n\u00a0 \u00a0 \u00a0 puts &#8220;Cannot connect to Couchbase Server: #{res.error}&#8221;<br \/>\n\u00a0 \u00a0 end<br \/>\n\u00a0 end<br \/>\nend<\/div>\n<\/div>\n<p>That&#039;s it for now! In the future we can expand this example to use more modern techniques like <a href=\"https:\/\/github.com\/igrigorik\/em-synchrony\/\">em-synchrony<\/a> and maybe websockets. Watch this blog for updates.<\/p>\n<h2>Bonus Points<\/h2>\n<p>Just logging might not be that interesting, with Couchbase Server you can perform simple analytics with View queries using Couchbase&#039;s incremental Map-Reduce awesomeness. For example, here is the Map function to get all entries in chronological order.<\/p>\n<div class=\"geshifilter\">\n<div class=\"text geshifilter-text\" style=\"font-family:monospace\">function (doc, meta) {<br \/>\n\u00a0 if (doc.message) {<br \/>\n\u00a0 \u00a0 if (doc.author == &#8220;[system]&#8221; &amp;&amp; doc.time) {<br \/>\n\u00a0 \u00a0 \u00a0 emit(new Date(doc.time), &#8220;*** &#8221; + doc.message);<br \/>\n\u00a0 \u00a0 } else {<br \/>\n\u00a0 \u00a0 \u00a0 emit(new Date(doc.time), &#8221; &#8221; + doc.message);<br \/>\n\u00a0 \u00a0 }<br \/>\n\u00a0 }<br \/>\n}<\/div>\n<\/div>\n<p>And the JSON output.<\/p>\n<div class=\"geshifilter\">\n<div class=\"text geshifilter-text\" style=\"font-family:monospace\">{&#8220;total_rows&#8221;:6,&#8221;rows&#8221;:[<br \/>\n\u00a0 {&#8220;id&#8221;:&#8221;log:1&#8243;,&#8221;key&#8221;:&#8221;2013-02-11T19:08:05.000Z&#8221;,&#8221;value&#8221;:&#8221;*** alice has joined&#8221;},<br \/>\n\u00a0 {&#8220;id&#8221;:&#8221;log:2&#8243;,&#8221;key&#8221;:&#8221;2013-02-11T19:08:18.000Z&#8221;,&#8221;value&#8221;:&#8221;*** bob has joined&#8221;},<br \/>\n\u00a0 {&#8220;id&#8221;:&#8221;log:3&#8243;,&#8221;key&#8221;:&#8221;2013-02-11T19:08:38.000Z&#8221;,&#8221;value&#8221;:&#8221; hi everyone&#8221;},<br \/>\n\u00a0 {&#8220;id&#8221;:&#8221;log:4&#8243;,&#8221;key&#8221;:&#8221;2013-02-11T19:08:48.000Z&#8221;,&#8221;value&#8221;:&#8221; hello, bob! how are you?&#8221;},<br \/>\n\u00a0 {&#8220;id&#8221;:&#8221;log:5&#8243;,&#8221;key&#8221;:&#8221;2013-02-11T19:08:58.000Z&#8221;,&#8221;value&#8221;:&#8221;*** alice has left&#8221;},<br \/>\n\u00a0 {&#8220;id&#8221;:&#8221;log:6&#8243;,&#8221;key&#8221;:&#8221;2013-02-11T19:09:01.000Z&#8221;,&#8221;value&#8221;:&#8221;*** bob has left&#8221;}<br \/>\n]}<\/div>\n<\/div>\n<p>Okay, that&#039;s really all for now. Enjoy this experimental new feature. It&#039;ll be fully supported in a future release. If you run into any trouble, please file an issue on the <a href=\"https:\/\/www.couchbase.com\/issues\/browse\/RCBC\/\">RCBC project issue tracker<\/a>. Fixes and contributions are always welcome too and it&#039;s Open Source under an Apache 2.0 License. You&#039;ll find the <a href=\"https:\/\/github.com\/couchbase\/couchbase-ruby-client\/\">sources on github<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As you may have noticed the new couchbase ruby gem has been released recently. The release 1.2.2 is mostly a maintenance release with several bug fixes, but yet you can try one new experimental feature: integration with EventMachine library. This [&hellip;]<\/p>\n","protected":false},"author":25,"featured_media":13873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[9407],"tags":[],"ppma_author":[8995],"class_list":["post-1819","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ruby"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Using Couchbase Ruby Gem with EventMachine - The Couchbase Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/es\/using-couchbase-ruby-gem-eventmachine\/\" \/>\n<meta property=\"og:locale\" content=\"es_MX\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Couchbase Ruby Gem with EventMachine\" \/>\n<meta property=\"og:description\" content=\"As you may have noticed the new couchbase ruby gem has been released recently. The release 1.2.2 is mostly a maintenance release with several bug fixes, but yet you can try one new experimental feature: integration with EventMachine library. This [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/es\/using-couchbase-ruby-gem-eventmachine\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2014-12-16T17:45:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T06:52:01+00:00\" \/>\n<meta name=\"author\" content=\"Sergey Avseyev, SDK Engineer, Couchbase\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@avsej\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sergey Avseyev, SDK Engineer, Couchbase\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-ruby-gem-eventmachine\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-ruby-gem-eventmachine\\\/\"},\"author\":{\"name\":\"Sergey Avseyev, SDK Engineer, Couchbase\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/e9181374f225c90084ec3ba86bdcfa2e\"},\"headline\":\"Using Couchbase Ruby Gem with EventMachine\",\"datePublished\":\"2014-12-16T17:45:47+00:00\",\"dateModified\":\"2025-06-14T06:52:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-ruby-gem-eventmachine\\\/\"},\"wordCount\":1324,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-ruby-gem-eventmachine\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"articleSection\":[\"Ruby\"],\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-ruby-gem-eventmachine\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-ruby-gem-eventmachine\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-ruby-gem-eventmachine\\\/\",\"name\":\"Using Couchbase Ruby Gem with EventMachine - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-ruby-gem-eventmachine\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-ruby-gem-eventmachine\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"datePublished\":\"2014-12-16T17:45:47+00:00\",\"dateModified\":\"2025-06-14T06:52:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-ruby-gem-eventmachine\\\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-ruby-gem-eventmachine\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-ruby-gem-eventmachine\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2022\\\/11\\\/couchbase-nosql-dbaas.png\",\"width\":1800,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/using-couchbase-ruby-gem-eventmachine\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using Couchbase Ruby Gem with EventMachine\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/admin-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/e9181374f225c90084ec3ba86bdcfa2e\",\"name\":\"Sergey Avseyev, SDK Engineer, Couchbase\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/288a892d231cf8c4e57ed0643e4681b4654a141361f6ec3c5b79ccd4d885e038?s=96&d=mm&r=g796ab283bd56fe3716a102ebe16daff6\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/288a892d231cf8c4e57ed0643e4681b4654a141361f6ec3c5b79ccd4d885e038?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/288a892d231cf8c4e57ed0643e4681b4654a141361f6ec3c5b79ccd4d885e038?s=96&d=mm&r=g\",\"caption\":\"Sergey Avseyev, SDK Engineer, Couchbase\"},\"description\":\"Sergey Avseyev is a SDK Engineer at Couchbase. Sergey Avseyev is responsible for development of Kafka connector, and underlying library, which implements DCP, Couchbase replication protocol. Also maintaining PHP SDK for Couchbase.\",\"sameAs\":[\"https:\\\/\\\/x.com\\\/avsej\"],\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/author\\\/sergey-avseyev\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Using Couchbase Ruby Gem with EventMachine - The Couchbase Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/es\/using-couchbase-ruby-gem-eventmachine\/","og_locale":"es_MX","og_type":"article","og_title":"Using Couchbase Ruby Gem with EventMachine","og_description":"As you may have noticed the new couchbase ruby gem has been released recently. The release 1.2.2 is mostly a maintenance release with several bug fixes, but yet you can try one new experimental feature: integration with EventMachine library. This [&hellip;]","og_url":"https:\/\/www.couchbase.com\/blog\/es\/using-couchbase-ruby-gem-eventmachine\/","og_site_name":"The Couchbase Blog","article_published_time":"2014-12-16T17:45:47+00:00","article_modified_time":"2025-06-14T06:52:01+00:00","author":"Sergey Avseyev, SDK Engineer, Couchbase","twitter_card":"summary_large_image","twitter_creator":"@avsej","twitter_misc":{"Written by":"Sergey Avseyev, SDK Engineer, Couchbase","Est. reading time":"6 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-ruby-gem-eventmachine\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-ruby-gem-eventmachine\/"},"author":{"name":"Sergey Avseyev, SDK Engineer, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/e9181374f225c90084ec3ba86bdcfa2e"},"headline":"Using Couchbase Ruby Gem with EventMachine","datePublished":"2014-12-16T17:45:47+00:00","dateModified":"2025-06-14T06:52:01+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-ruby-gem-eventmachine\/"},"wordCount":1324,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-ruby-gem-eventmachine\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","articleSection":["Ruby"],"inLanguage":"es","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/using-couchbase-ruby-gem-eventmachine\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-ruby-gem-eventmachine\/","url":"https:\/\/www.couchbase.com\/blog\/using-couchbase-ruby-gem-eventmachine\/","name":"Using Couchbase Ruby Gem with EventMachine - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-ruby-gem-eventmachine\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-ruby-gem-eventmachine\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","datePublished":"2014-12-16T17:45:47+00:00","dateModified":"2025-06-14T06:52:01+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-ruby-gem-eventmachine\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/using-couchbase-ruby-gem-eventmachine\/"]}]},{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-ruby-gem-eventmachine\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","width":1800,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/using-couchbase-ruby-gem-eventmachine\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Using Couchbase Ruby Gem with EventMachine"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"El blog de Couchbase","description":"Couchbase, la base de datos NoSQL","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"El blog de Couchbase","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/e9181374f225c90084ec3ba86bdcfa2e","name":"Sergey Avseyev, Ingeniero SDK, Couchbase","image":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/secure.gravatar.com\/avatar\/288a892d231cf8c4e57ed0643e4681b4654a141361f6ec3c5b79ccd4d885e038?s=96&d=mm&r=g796ab283bd56fe3716a102ebe16daff6","url":"https:\/\/secure.gravatar.com\/avatar\/288a892d231cf8c4e57ed0643e4681b4654a141361f6ec3c5b79ccd4d885e038?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/288a892d231cf8c4e57ed0643e4681b4654a141361f6ec3c5b79ccd4d885e038?s=96&d=mm&r=g","caption":"Sergey Avseyev, SDK Engineer, Couchbase"},"description":"Sergey Avseyev es Ingeniero SDK en Couchbase. Sergey Avseyev es responsable del desarrollo del conector Kafka, y la biblioteca subyacente, que implementa DCP, el protocolo de replicaci\u00f3n de Couchbase. Tambi\u00e9n mantiene PHP SDK para Couchbase.","sameAs":["https:\/\/x.com\/avsej"],"url":"https:\/\/www.couchbase.com\/blog\/es\/author\/sergey-avseyev\/"}]}},"acf":[],"authors":[{"term_id":8995,"user_id":25,"is_guest":0,"slug":"sergey-avseyev","display_name":"Sergey Avseyev, SDK Engineer, Couchbase","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/288a892d231cf8c4e57ed0643e4681b4654a141361f6ec3c5b79ccd4d885e038?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/posts\/1819","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/comments?post=1819"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/posts\/1819\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/media\/13873"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/media?parent=1819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/categories?post=1819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/tags?post=1819"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/ppma_author?post=1819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}