I’m looking for suggestions for an in-memory database or other type of store that syncs to the file system (preferably as a single file) to store small, text-only documents (notes) and additional metadata.

It should preferably be made purely with Rust and have no dependencies to outside libraries like SQLite (without the dependency to the sqlite library in the system it would be my first choice). Also it shouldn’t depend on any server/service running in the system.

It should support relational data (but not necessarily relational as in SQL and relational databases) to allow fast and easy searching and retrieval of data.

So far I (from the crate descriptions only) I found RedDB. the rql crate looks promising, too, even though I’ll have to write the sync to the filesystem myself.

Are there more suggestions?

  • DessalinesA
    link
    fedilink
    arrow-up
    7
    ·
    edit-2
    3 years ago

    I’m not a big fan of memory-only stores, but I believe sled is entirely in memory. @asonix@lemmy.ml is that correct? Its key-value, so not SQL-like, so maybe not the best for your use case.

    I do really recommend using sqlite, or if its server-based, postgres. These aren’t written in rust obvi but they have great performance, and there are plenty of rust libraries to talk to them.

    Also if your use case is storing text-documents, I def would not use a memory store.

    • Aode (He/They)
      link
      fedilink
      arrow-up
      3
      ·
      3 years ago

      Sled is my go-to key value store in Rust. It flushes to disk every 500ms by default iirc

      • Aode (He/They)
        link
        fedilink
        arrow-up
        3
        ·
        3 years ago

        It also has .flush() and .flush_async() to flush inline with your application if you need that

    • Victor von VoidOP
      link
      fedilink
      arrow-up
      2
      ·
      3 years ago

      I definitely don’t want a database that needs to be installed first as I want to write a tool that can be thrown at a user and is instantly usable. So PostgreSQL and similar DBs are not an option. My problem with SQLite is, that it’s not available everywhere, so I’d have to ship it with my app which again leads to a more complex setup. I’ll have a look at sled, though, thanks!

        • Victor von VoidOP
          link
          fedilink
          arrow-up
          2
          ·
          3 years ago

          I mean: not already installed on every system. Don’t get me wrong: I like SQLite and used it in several projects. I just need something that doesn’t have to be installed/downloaded/whatever first. I just want to deploy a single executable and not worry about the dependencies.

          • pinknoise
            link
            fedilink
            arrow-up
            6
            ·
            edit-2
            3 years ago

            You can statically link sqlite into your program, rusqlite has that as a feature flag iirc

  • tmpod@lemmy.pt
    link
    fedilink
    arrow-up
    3
    ·
    3 years ago

    To add to what others have said, you could try RocksDB and use one of the many Rust wrappers available. I have never used it, but I’ve heard great things from it, and afaik the Conduit project is working on moving from sled to RocksDB. Maybe you could hop on their Matrix channel and chat about this :)

      • tmpod@lemmy.pt
        link
        fedilink
        arrow-up
        2
        ·
        3 years ago

        I hope you find something that suits you well :D
        Curious to see what you settle with in the end hehe

        • Victor von VoidOP
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          3 years ago

          For a work project (a portable maintenance and incident management application) we’ll go with SQLite/rusqlite because of familiarity and some other reasons. And it can be linked statically, as suggested by @pinknoise

          For a private project (a note taking app … yeah, I know, there are already thousands, but I need a real project for learning more Rust) I’m still playing around with the options.