基于LevelDB的一个Objective-C数据库:Objective-LevelDB

jopen 9年前

一个基于Google's LevelDB的Objective-C数据库。 LevelDB是一个由Google开发的快速嵌入式key-value存储。

Objective-leveldb

An Objective-C database library built over Google's LevelDB

View the Project on GitHubmatehat/Objective-LevelDB

安装

By far, the easiest way to integrate this library in your project is by using CocoaPods.

  1. Have Cocoapods installed, if you're not already
  2. In your Podfile, add the line

    pod 'Objective-LevelDB'
  3. Runpod install

  4. Add thelibc++.dylibFramework to your project.
  5. Make something awesome.

How to use

Creating/Opening a database file on disk

LevelDB *ldb = [LevelDB databaseInLibraryWithName:@"test.ldb"]; 
Setup Encoder/Decoder blocks
ldb.encoder = ^ NSData * (LeveldBKey *key, id object) {    // return some data, given an object  }  ldb.decoder = ^ id (LeveldBKey *key, NSData * data) {    // return an object, given some data  }

NSMutableDictionary-like API
[ldb setObject:@"laval" forKey:@"string_test"];  NSLog(@"String Value: %@", [ldb objectForKey:@"string_test"]);    [ldb setObject:@{@"key1" : @"val1", @"key2" : @"val2"} forKey:@"dict_test"];  NSLog(@"Dictionary Value: %@", [ldb objectForKey:@"dict_test"]);

项目主页:http://www.open-open.com/lib/view/home/1441091268456