PickleDB-rs is a lightweight and simple key-value store. It is a Rust version for Python's PickleDB

Overview

PickleDB

Build Status Rust test Rust audit Crate API

PickleDB is a lightweight and simple key-value store written in Rust, heavily inspired by Python's PickleDB

PickleDB is fun and easy to use

use pickledb::{PickleDb, PickleDbDumpPolicy, SerializationMethod};

fn main() {

    // create a new DB with AutoDump (meaning every change is written to the file)
    // and with Json serialization (meaning DB will be dumped to file as a Json object)
    let mut db = PickleDb::new("example.db", PickleDbDumpPolicy::AutoDump, SerializationMethod::Json);

    // set the value 100 to the key 'key1'
    db.set("key1", &100).unwrap();

    // print the value of key1
    println!("The value of key1 is: {}", db.get::<i32>("key1").unwrap());

    // load the DB from the same file
    let db2 = PickleDb::load("example.db", PickleDbDumpPolicy::DumpUponRequest, SerializationMethod::Json).unwrap();

    // print the value of key1
    println!("The value of key1 as loaded from file is: {}", db2.get::<i32>("key1").unwrap());
}

Installation

This crate works with Cargo and can be found in crates.io Add this to your Cargo.toml:

[dependencies]
pickledb = "0.4.1"

Documentation

All documentation for this crate can be found in docs.rs

Examples

There are currently two examples shipped with PickleDB:

  • Hello World which shows the basic usage of PickleDB: create a new DB, load a DB from file, get/set key-value pairs of different types, and more
  • Lists which shows how to use lists in PickleDB: create new lists, add/remove items from lists, retrieve items from lists, remove lists, and more

Changelog

Version 0.4.1

  • Bump up dependencies versions to fix vulnerabilities found in few of them

Version 0.4.0

  • Changed all doc tests from ignore to no_run so generated docs don't contain untested warnings
  • Changed both instances of lextend to take iterators of references rather than a slice of values
  • Fixed bug in load_test()
  • Fixed rustfmt and clippy warnings
  • Added examples to Cargo.toml to allow them to be run via Cargo

Version 0.3.0

  • Added new serialization options. Now PickleDB supports JSON, Bincode, YAML and CBOR serializations
  • Added proper error handling (Issue #3)
  • Use Path and PathBuf instead of strings to describe DB paths
  • Better organization of the code

Version 0.2.0

Comments
  • Perform cargo audit on nightly builds & do CI in github actions

    Perform cargo audit on nightly builds & do CI in github actions

    Hi again @seladb =) I beleive we talked briefly about doing cargo audit in CI. Well now I've set it up for my little project over at https://github.com/jensim/bitbucket_server_cli and i think it works great so far. Wanna try it out? Best regards Jens

    opened by jensim 13
  • Addition of Nanoserde backend for smaller dependency tree and faster compile

    Addition of Nanoserde backend for smaller dependency tree and faster compile

    Wanted to use pickleDB, but trying to avoid having quote + syn in my build tree. This change optionally reduces the number of deps for the library to one, with similar performance to bincode according to the test suite.

    opened by knickish 6
  • `DumpUponRequest` policy no longer dumps on `Drop`

    `DumpUponRequest` policy no longer dumps on `Drop`

    I was surprised to discover that PickleDbDumpPolicy::DumpUponRequest still causes a dump on Drop. It's not clear to me if this is intentional or a bug, so for now I propose a new policy that removes this unexpected implicit dump for applications that wish to opt-in while retaining the existing behaviour for other users of PickleDbDumpPolicy::DumpUponRequest.

    This PR removes this unexpected dump.

    opened by mvines 5
  • Error handling in this rust version

    Error handling in this rust version

    There is almost no error/exception-handling code in Python version's Pickledb.It works because Python use try/except and exception to deal with errors and failures.You can always put a try/except block in your code that calling the Pickledb's API.Which will handle the exceptions raised from the internal of the Pickledb.In Rust's version,there is the same situation.But Rust don't use exception,is it a good choice to just panic the thread if something went wrong in internal code.

    This question is raised because I saw so many unwrap and expect in Pickledb-rs's code.Would it not be more robust if use error and option?Any plan for this?

    opened by songzhi 5
  • Feature cleanup

    Feature cleanup

    This branch just does the work related to allowing the feature flags to actually be used. Currently only some combinations will work, this pr makes it so that any combination of the serialization types may be used.

    opened by knickish 3
  • Appreciation and Query

    Appreciation and Query

    Am really happy to have come across this, am an aspiring Rust developer and it really appeals to me, and so this year i want to write a small database system and so i have been researching on the matter, and have truly taking a liking to this, seems simple and useable, and gentle to use to,

    And so, i would love to inquire, what would be the difference between using this crate vs simply writing and reading to a file probably serializing with json, cause what am getting so far is that either files would be loaded to memory at runtime and neither are accesed from disk, well, one difference i do spot is that for sure handling the data should be much easier using this and also it has a few more in built features to take advantage of, so yeah, seems pretty neat, could you kindly enlighten me more on this matter, would be highly appreciated,

    question 
    opened by quadroli 3
  • Change `lextend` to take iterators of references and fix clippy/rustfmt warnings

    Change `lextend` to take iterators of references and fix clippy/rustfmt warnings

    I've made multiple commits to this PR, any of which can be removed or made into standalone PRs if you prefer.

    The main intent was to change the two instances of lextend() to take references to values rather than actual values. I ran into a few other fairly trivial issues while doing this and bundled fixes for them all into this PR.

    opened by Fraser999 3
  • Bumping versions due to a flaw found in serde_cbor-0.9.0

    Bumping versions due to a flaw found in serde_cbor-0.9.0

    Flaw found in transitive dependency failed my build https://travis-ci.org/github/jensim/bitbucket_server_cli/builds/667567270 I added a audit step to the build as well, if you think its smart?

    opened by jensim 2
  • Make the examples runnable by cargo.

    Make the examples runnable by cargo.

    This allows us to run the examples by calling e.g. 'cargo run --example hello_world'

    It also means the examples get compiled when calling 'cargo test'.

    opened by Fraser999 2
  • Allow turning off file formats with features

    Allow turning off file formats with features

    Resolves #23

    Not sure I like how I had to handle most of the match blocks, since I couldn't find an easy way to disable enum fields with features, but it works. Brings size of hello_world example from 1.2 MB to 670 KB, and lists from 1.2 MB to 673 KB on macOS.

    opened by ravenclaw900 1
  • featurize json, yaml, bincode and cbor serialization

    featurize json, yaml, bincode and cbor serialization

    I added features for the different serialization methods, to lower the library size and necessary dependencies. Default is json. Unfortunately running the tests is only possible using all features, because of the parameterized rstests. Maybe you have an idea how to solve this problem.

    opened by simonsilvalauinger 1
Releases(0.5.1)
  • 0.5.1(Apr 26, 2022)

  • 0.5.0(Apr 20, 2022)

  • 0.3.0(Feb 5, 2019)

    Please find crate information here: https://crates.io/crates/pickledb/0.3.0 Documentation can be found here: https://docs.rs/crate/pickledb/0.3.0

    Source code(tar.gz)
    Source code(zip)
  • 0.2.0(Feb 5, 2019)

    Please find crate information here: https://crates.io/crates/pickledb/0.2.0 Documentation can be found here: https://docs.rs/crate/pickledb/0.2.0

    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Feb 5, 2019)

    Please find crate information here: https://crates.io/crates/pickledb/0.1.0 Documentation can be found here: https://docs.rs/crate/pickledb/0.1.0

    Source code(tar.gz)
    Source code(zip)
Owner
null
RedisLess is a fast, lightweight, embedded and scalable in-memory Key/Value store library compatible with the Redis API.

RedisLess is a fast, lightweight, embedded and scalable in-memory Key/Value store library compatible with the Redis API.

Qovery 145 Nov 23, 2022
A simple embedded key-value store written in rust as a learning project

A simple embedded key-value store written in rust as a learning project

Blobcode 1 Feb 20, 2022
Pure rust embeddable key-value store database.

MHdb is a pure Rust database implementation, based on dbm. See crate documentation. Changelog v1.0.3 Update Cargo.toml v1.0.2 Update Cargo.toml v1.0.1

Magnus Hirth 7 Dec 10, 2022
Log structured append-only key-value store from Rust In Action with some enhancements.

riakv Log structured, append only, key value store implementation from Rust In Action with some enhancements. Features Persistent key value store with

Arindam Das 5 Oct 29, 2022
A LSM-based Key-Value Store in Rust

CobbleDB A LSM-based Key-Value Store in Rust Motivation There is no open-source LSM-based key-value store in Rust natively. Some crates are either a w

Yizheng Jiao 2 Oct 25, 2021
A rust Key-Value store based on Redis.

Key-Value Store A Key-Value store that uses Redis to store data. Built using an async web framework in Rust with a full Command-Line interface and log

Miguel David Salcedo 0 Jan 14, 2022
RefineDB - A strongly-typed document database that runs on any transactional key-value store.

RefineDB - A strongly-typed document database that runs on any transactional key-value store.

Heyang Zhou 375 Jan 4, 2023
A sessioned Merkle key/value store

storage A sessioned Merkle key/value store The crate was designed to be the blockchain state database. It provides persistent storage layer for key-va

Findora Foundation 15 Oct 25, 2022
🔥🌲 High-performance Merkle key/value store

merk High-performance Merkle key/value store Merk is a crypto key/value store - more specifically, it's a Merkle AVL tree built on top of RocksDB (Fac

Nomic 189 Dec 13, 2022
A simple key value database for storing simple structures.

Perdia-DB A simple key value database for storing simple structures. No nesting of structures is supported, but may be implemented in the future. Toke

Perdia 4 May 24, 2022
A fast and simple in-memory database with a key-value data model written in Rust

Segment Segment is a simple & fast in-memory database with a key-value data model written in Rust. Features Dynamic keyspaces Keyspace level control o

Segment 61 Jan 5, 2023
AgateDB is an embeddable, persistent and fast key-value (KV) database written in pure Rust

AgateDB is an embeddable, persistent and fast key-value (KV) database written in pure Rust. It is designed as an experimental engine for the TiKV project, and will bring aggressive optimizations for TiKV specifically.

TiKV Project 535 Jan 9, 2023
A "blazingly" fast key-value pair database without bloat written in rust

A fast key-value pair in memory database. With a very simple and fast API. At Xiler it gets used to store and manage client sessions throughout the pl

Arthur 16 Dec 16, 2022
Immutable Ordered Key-Value Database Engine

PumpkinDB Build status (Linux) Build status (Windows) Project status Usable, between alpha and beta Production-readiness Depends on your risk toleranc

null 1.3k Jan 2, 2023
Distributed transactional key-value database, originally created to complement TiDB

Website | Documentation | Community Chat TiKV is an open-source, distributed, and transactional key-value database. Unlike other traditional NoSQL sys

TiKV Project 12.4k Jan 3, 2023
CLI tool to work with Sled key-value databases.

sledtool CLI tool to work with Sled key-value databases. $ sledtool --help Usage: sledtool <dbpath> <command> [<args>] CLI tool to work with Sled da

Vitaly Shukela 27 Sep 26, 2022
LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.

LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values. Authors: Sanjay Ghem

Google 31.5k Jan 1, 2023
ForestDB - A Fast Key-Value Storage Engine Based on Hierarchical B+-Tree Trie

ForestDB is a key-value storage engine developed by Couchbase Caching and Storage Team, and its main index structure is built from Hierarchic

null 1.2k Dec 26, 2022
A Key-Value data storage system. - dorea db

Dorea DB ?? Dorea is a key-value data storage system. It is based on the Bitcask storage model Documentation | Crates.io | API Doucment 简体中文 | English

ZhuoEr Liu 112 Dec 2, 2022