{"id":13990283,"url":"https://github.com/matehat/Objective-LevelDB","last_synced_at":"2025-07-22T12:31:30.843Z","repository":{"id":8363857,"uuid":"9929641","full_name":"matehat/Objective-LevelDB","owner":"matehat","description":"An Objective-C database library built over Google's LevelDB","archived":false,"fork":false,"pushed_at":"2020-02-24T18:39:48.000Z","size":478,"stargazers_count":453,"open_issues_count":10,"forks_count":89,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-05-24T11:06:19.270Z","etag":null,"topics":["cocoapods","database","database-library","leveldb","objective-c"],"latest_commit_sha":null,"homepage":"http://matehat.github.io/Objective-LevelDB","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matehat.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-08T06:14:43.000Z","updated_at":"2025-04-29T09:21:33.000Z","dependencies_parsed_at":"2022-08-07T04:01:02.361Z","dependency_job_id":null,"html_url":"https://github.com/matehat/Objective-LevelDB","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/matehat/Objective-LevelDB","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matehat%2FObjective-LevelDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matehat%2FObjective-LevelDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matehat%2FObjective-LevelDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matehat%2FObjective-LevelDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matehat","download_url":"https://codeload.github.com/matehat/Objective-LevelDB/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matehat%2FObjective-LevelDB/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266496006,"owners_count":23938644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapods","database","database-library","leveldb","objective-c"],"created_at":"2024-08-09T13:02:31.643Z","updated_at":"2025-07-22T12:31:25.826Z","avatar_url":"https://github.com/matehat.png","language":"Objective-C","funding_links":[],"categories":["Objective-C"],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/matehat/Objective-LevelDB.svg?style=svg)](https://circleci.com/gh/matehat/Objective-LevelDB)\n\n## Introduction\n\nAn Objective-C database library built over [Google's LevelDB](http://code.google.com/p/leveldb), a fast embedded key-value store written by Google.\n\n## Installation\n\nBy far, the easiest way to integrate this library in your project is by using [CocoaPods][1].\n\n1. Have [Cocoapods][1] installed, if you don't already\n2. In your Podfile, add the line \n\n        pod 'Objective-LevelDB'\n\n3. Run `pod install`\n4. Make something awesome.\n\n## How to use\n\n#### Creating/Opening a database file on disk\n\n```objective-c\nLevelDB *ldb = [LevelDB databaseInLibraryWithName:@\"test.ldb\"];\n```\n\n##### Setup Encoder/Decoder blocks\n\nBy default, any object you store will be encoded and decoded using `NSKeyedArchiver`/`NSKeyedUnarchiver`. You can customize this by providing `encoder` and `decoder` blocks, like this:\n\n```objective-c\nldb.encoder = ^ NSData * (LevelDBKey *key, id object) {\n  // return some data, given an object\n}\nldb.decoder = ^ id (LevelDBKey *key, NSData * data) {\n  // return an object, given some data\n}\n```\n\n#####  NSMutableDictionary-like API\n\n```objective-c\nldb[@\"string_test\"] = @\"laval\"; // same as:\n[ldb setObject:@\"laval\" forKey:@\"string_test\"];\n\nNSLog(@\"String Value: %@\", ldb[@\"string_test\"]); // same as:\nNSLog(@\"String Value: %@\", [ldb objectForKey:@\"string_test\"]);\n\n[ldb setObject:@{@\"key1\" : @\"val1\", @\"key2\" : @\"val2\"} forKey:@\"dict_test\"];\nNSLog(@\"Dictionary Value: %@\", [ldb objectForKey:@\"dict_test\"]);\n\n```\nAll available methods can be found in its [header file](https://github.com/matehat/Objective-LevelDB/blob/master/Classes/LevelDB.h) (documented).\n\n##### Enumeration\n\n```objective-c\n[ldb enumerateKeysAndObjectsUsingBlock:^(LevelDBKey *key, id value, BOOL *stop) {\n    // This step is necessary since the key could be a string or raw data (use NSDataFromLevelDBKey in that case)\n    NSString *keyString = NSStringFromLevelDBKey(key); // Assumes UTF-8 encoding\n    // Do something clever\n}];\n\n// Enumerate with options\n[ldb enumerateKeysAndObjectsBackward:TRUE\n                              lazily:TRUE       // Block below will have a block(void) instead of id argument for value\n                       startingAtKey:someKey    // Start iteration there (NSString or NSData)\n                 filteredByPredicate:predicate  // Only iterate over values matching NSPredicate\n                           andPrefix:prefix     // Only iterate over keys prefixed with something \n                          usingBlock:^(LevelDBKey *key, void(^valueGetter)(void), BOOL *stop) {\n                             \n    NSString *keyString = NSStringFromLevelDBKey(key);\n    \n    // If we had wanted the value directly instead of a valueGetter block, we would've set the \n    // above 'lazily' argument to FALSE\n    id value = valueGetter();\n}]\n```\nMore iteration methods are available, just have a look at the [header section](https://github.com/matehat/Objective-LevelDB/blob/master/Classes/LevelDB.h)\n\n##### Snapshots, NSDictionary-like API (immutable)\n\nA snapshot is a readonly interface to the database, permanently reflecting the state of \nthe database when it was created, even if the database changes afterwards.\n\n```objective-c\nLDBSnapshot *snap = [ldb newSnapshot]; // You get ownership of this variable, so in non-ARC projects,\n                                       // you'll need to release/autorelease it eventually\n[ldb removeObjectForKey:@\"string_test\"];\n\n// The result of these calls will reflect the state of ldb when the snapshot was taken\nNSLog(@\"String Value: %@\", [snap objectForKey:@\"string_test\"]);\nNSLog(@\"Dictionary Value: %@\", [ldb objectForKey:@\"dict_test\"]);\n```\n\nAll available methods can be found in its [header file](https://github.com/matehat/Objective-LevelDB/blob/master/Classes/LDBSnapshot.h)\n\n##### Write batches, atomic sets of updates\n\nWrite batches are a mutable proxy to a `LevelDB` database, accumulating updates\nwithout applying them, until you do using `-[LDBWritebatch apply]`\n\n```objective-c\nLDBWritebatch *wb = [ldb newWritebatch];\n[wb setObject:@{ @\"foo\" : @\"bar\" } forKey: @\"another_test\"];\n[wb removeObjectForKey:@\"dict_test\"];\n\n// Those changes aren't yet applied to ldb\n// To apply them in batch, \n[wb apply];\n```\n\nAll available methods can be found in its [header file](https://github.com/matehat/Objective-LevelDB/blob/master/Classes/LDBWriteBatch.h)\n\n##### LevelDB options\n\n```objective-c\n// The following values are the default\nLevelDBOptions options = [LevelDB makeOptions];\noptions.createIfMissing = true;\noptions.errorIfExists   = false;\noptions.paranoidCheck   = false;\noptions.compression     = true;\noptions.filterPolicy    = 0;      // Size in bits per key, allocated for a bloom filter, used in testing presence of key\noptions.cacheSize       = 0;      // Size in bytes, allocated for a LRU cache used for speeding up lookups\n\n// Then, you can provide it when initializing a db instance.\nLevelDB *ldb = [LevelDB databaseInLibraryWithName:@\"test.ldb\" andOptions:options];\n```\n\n##### Per-request options\n\n```objective-c\ndb.safe = true; // Make sure to data was actually written to disk before returning from write operations.\n[ldb setObject:@\"laval\" forKey:@\"string_test\"];\n[ldb setObject:[NSDictionary dictionaryWithObjectsAndKeys:@\"val1\", @\"key1\", @\"val2\", @\"key2\", nil] forKey:@\"dict_test\"];\ndb.safe = false; // Switch back to default\n\ndb.useCache = false; // Do not use DB cache when reading data (default to true);\n```\n\n##### Concurrency\n\nAs [Google's documentation states][2], updates and reads from a leveldb instance do not require external synchronization\nto be thread-safe. Write batches do, and we've taken care of it, by isolating every `LDBWritebatch` it inside a serial dispatch \nqueue, and making every request dispatch *synchronously* to it. So use it from wherever you want, it'll just work.\n\nHowever, if you are using something like JSONKit for encoding data to JSON in the database, and you are clever enough to \npreallocate a `JSONDecoder` instance for all data decoding, beware that this particular object is *not* thread-safe, and you will\nneed to take care of it manually.\n\n### Testing\n\nIf you want to run the tests, you will need Xcode 5, as the test suite uses the new XCTest. \n\nClone this repository and, once in it,\n\n```bash\n./setup-test.sh\ncd Tests \u0026\u0026 open Objective-LevelDB.xcworkspace\n```\n\nCurrently, all tests were setup to work with the iOS test suite.\n\n### License\n\nDistributed under the [MIT license](LICENSE)\n\n[1]: http://cocoapods.org\n[2]: http://leveldb.googlecode.com/svn/trunk/doc/index.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatehat%2FObjective-LevelDB","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatehat%2FObjective-LevelDB","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatehat%2FObjective-LevelDB/lists"}