基于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.
- Have Cocoapods installed, if you're not already
-
In your Podfile, add the line
pod 'Objective-LevelDB'
-
Runpod install
- Add thelibc++.dylibFramework to your project.
- Make something awesome.
How to use
Creating/Opening a database file on disk
LevelDB *ldb = [LevelDB databaseInLibraryWithName:@"test.ldb"];
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"]);