Skip to content
A dirt simple nosql db for Dart (based on node-dirty)
Dart Shell
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
.gitignore
LICENSE
README.md
pubspec.yaml

README.md

Dart Dirty

The dart dirty library is persistent HashMap for Dart.

Create a new database with the constructor:

var db = new Dirty('test/test.db');

Open an existing database with the same constructor:

var db = new Dirty('test/test.db');

Then use the usual HashMap methods to add records:

db['everything'] = {'answer': 42};

And to remove records:

db.remove('everything');

To ensure that everything is written to the filesystem, it is best to properly close a database:

db.close();

Performance

I have not really optimized this yet. Using readAsLines to read DB records seems less than ideal, but it actually works fairly well. Writing could probably be sped up if data was buffered more, but I focused on read for the first pass.

If you would like to improve, see the test/mk_perf_db.dart and test/perf.dart scripts. The former creates a 100,000 record DB and the latter reads it back in. On my machine the former takes ~4 minutes to write and ~10 seconds to read. Performance patches welcome!

Contributors

License

This software is licensed under the MIT License.

Copyright Chris Strom, 2014.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.