Search:

Search all manuals
Search this manual
Manual
Couchbase Client Library Ruby 1.1
Community Wiki and Resources
Download Client Library
RDoc
Ruby Client Library
SDK Forum
Additional Resources
Community Wiki
Community Forums
Couchbase SDKs
Parent Section
3 Ruby Method Summary
Chapter Sections
Chapters

3.2. Asynchronous Method Calls

In addition, the library also supports a range of asynchronous methods that can be used to store, update and retrieve values without having to explicitly wait for a response. For asynchronous operations, the SDK will return control to the calling method without blocking the current thread. You can pass the block to a method and it will be called with the result when the operations completes. You need to use an event loop, namely an event loop in the form of arun .. do |return| block to perform asynchronous calls with the Ruby SDK:

couchbase = Couchbase.connect(:async => true)

couchbase.run do |conn|
      conn.get("foo") {|ret| puts ret.value}
      conn.set("bar", "baz")
end

The asynchronous callback will recieve an instance of Couchbase::Result which can respond to several methods: