couchbase-iOS 轻量级的开源 NoSQL 数据库引擎

3,067 阅读3分钟
原文链接: github.com

(aka TouchDB 1.5)

Couchbase Lite is a lightweight, document-oriented (NoSQL), syncable database engine suitable for embedding into mobile or desktop apps.

Think of it this way: If Apache CouchDB is MySQL, and Couchbase Server is Oracle, then Couchbase Lite is SQLite.

Lightweight means:

  • Embedded: The database engine is a library linked into the app, not a separate server process.
  • Small code size: currently under 400kbytes. This is important to mobile apps, which are often downloaded over cell networks.
  • Quick startup time on relatively-slow CPUs: currently under 50ms on recent iPhones.
  • Low memory usage with typical mobile data-sets. The expectation is the number of documents will not be huge, although there may be sizable multimedia attachments.
  • "Good enough" performance with these CPUs and data-sets. (Exact figures depend on your data and application, of course.)

Document-oriented means:

  • Like other modern databases (Couchbase, CouchDB, MongoDB...) it stores records in flexible JSON format instead of requiring predefined schemas or normalization.
  • Records/documents can have arbitrary-sized binary attachments, like multimedia content.
  • Your application's data format can evolve over time without any need for explicit migrations.
  • Map/reduce indexing allows fast lookups without needing to use special query languages.

Syncable means:

  • Any two copies of a database can be brought into sync via an efficient, reliable, proven REST-based [[protocol|Replication-Algorithm]] pioneered by Apache CouchDB.
  • Interoperates with CouchDB, BigCouch and PouchDB, and with hosted services like Cloudant and IrisCouch.
  • Sync can be on-demand or continuous (with a latency of a few seconds).
  • The sync engine supports intermittent and unreliable network connections.
  • Conflicts can be detected and resolved, with app logic in full control of merging.
  • Revision trees allow for complex replication topologies, including server-to-server (for multiple data centers) and peer-to-peer, without data loss or false conflicts.

The native APIs are Objective-C (iOS, Mac) and Java (Android), but an optional internal REST API adapter allows it to be called from other languages like JavaScript and C#, for use in apps built with PhoneGap, Titanium or MonoTouch.

Couchbase Lite is still in development. It's not finished or production-quality yet! If you are looking for a stable release suitable for use in shipping apps, please use TouchDB, the earlier 1.0 version. The API is slightly different, but upgrading to Couchbase Lite will be fairly easy. (Why the name change? The project history explains it.)

More Information

Platforms

  • Mac OS X -- 10.7.2 or higher.
  • iOS -- 5.0 or higher.
  • Android / Java -- Has its own source base and repository.

Requirements

  • It's written in Objective-C.
  • Xcode 4.5+ is required to build it (Clang 3.1+, with GNUstep).
  • Runtime system requirements for Apple platforms are iOS 5+, or Mac OS X 10.7.2+.

Development Status

Couchbase Lite is still in pre-alpha development status, as of March 2013. We expect it to go beta this summer.

If you are looking for a stable release suitable for use in shipping apps, please use TouchDB, the earlier 1.0 version. The API is slightly different, but upgrading to Couchbase Lite will be fairly easy.

Credits

Design, coding: Jens Alfke (jens@couchbase.com)
Contributions from: Alexander Edge, Chris Kau, David Venable, Derek Clarkson, Fabien Franzen, fcandalija, J Chris Anderson, Marty Schoch, Mike Lamb, Paul Mietz Egli, Robin Lu
Technical advice from: Damien Katz, Filipe Manana, and several other gurus on the CouchDB mailing list

License

  • Couchbase Lite itself is under the Apache License 2.0.
  • FMDB, by Gus Mueller, is under the MIT License.
  • Google Toolbox For Mac is under the Apache License 2.0.
  • CocoaHTTPServer, by Robbie Hanson, is under the BSD License.
  • MYUtilities (portions of which are copied into the vendor/MYUtilities directory) is under the BSD License. (But note that I, Jens, wrote MYUtilities and would have no problem re-licensing it under Apache for use here.)

Downloading Couchbase Lite

  • Latest 'stable' build. (May not be stable by objective standards, considering the project is pre-alpha. But stable-er than the hourly builds.)
  • Recent builds (built hourly after any commits. Each archive is timestamped.)

Building Couchbase Lite

On a Mac

(You might prefer to just download the latest build. But if you want to build it yourself...)

For full details see the wiki page. The basic steps are:

  1. Clone the Couchbase Lite repository to your local disk.
  2. In that directory run "git submodule init" and then "git submodule update". This will clone the dependent library repos (such as FMDB and MYUtilities) into the vendor/ subdirectory.
  3. Open the Xcode project and build the "Mac Framework" and/or "iOS Framework" schemes.