Blog.

by Jon Crosby

JSON Meets Tokyo Cabinet (and More!): CloudKit 0.11.0 Released

CloudKit 0.11.0 is out with exciting new features!

Tokyo Cabinet

CloudKit now supports Tokyo Cabinet as its storage system. If you haven’t checked out Tokyo Cabinet, take a moment to read Ilya Grigorik’s overview or check out its main site. You will find it to be an extremely fast and compelling storage system.

While Tokyo Cabinet is impressive, it comes with the cost of a binary dependency. Although it took only a moment to install it on my Mac using John Mettraux’s simple instructions, I didn’t want to sacrifice CloudKit’s install-and-go development experience. So, I added a pure Ruby store that mimics the Tokyo Table API (as exposed to CloudKit via Rufus::Tokyo). This is the default store used by CloudKit until you specify otherwise. See the README for an example of using the native Tokyo Table backend when you’re ready.

Making the switch to Tokyo Cabinet paves the way for the final significant piece of CloudKit’s architecture — JSONQuery support. With super-fast storage, a discoverable API, built-in Open Web auth (using OpenID and OAuth), and fully searchable data with JSONQuery, CloudKit will cover a wide range of use cases. Not only this, but it fits in the Rack stack, so it can be used alongside your other favorite frameworks and middleware.

CloudKit::Resource

Unsatisfied with “alongside,” CloudKit has made the move to “inside” too. Prior to this release, the only interface to CloudKit was through its HTTP/REST web service. With the 0.11 release, you can also use it in a manner similar to DataMapper or ActiveRecord with one small difference; instead of having to map arbitrary models to SQL, CloudKit provides a single Resource model that represents a JSON document and all of its metadata (URI, ETag, Last-Modified date, etc.). There are more details in the CloudKit docs, but here are a few examples:

JQuery Plugin

Still early in development, a working jQuery plugin is available for CloudKit. The plugin provides an in-browser queryable JSON database that automatically loads and configures itself using the metadata provided by CloudKit. For every resource collection you are hosting with CloudKit, the plugin will expose a local mirror that amounts to a queryable JSON array (implemented using TaffyDB patched for asynchronous operation). Updating your local data is simple and is synchronized with the matching web service automatically.

Here are some examples from the README:

Clouder: A Ruby API for CloudKit

For across-the-network access to CloudKit using Ruby, Demetrius Nunes has put together a library called Clouder. This use case matches the way many are using CouchDB as an ORM backend. If you’re interested in using CloudKit in this manner, be sure to fork Demetrius’s project on GitHub and contribute.

IRC

Beyond the existing site, GitHub repository, Twitter, and mailing list, there is now #cloudkit on Freenode for interested hackers. Feel free to drop in and participate in the next release or ask questions about using CloudKit in your own projects.