https://slatedb.io logo
Hi there, Tweaking the example provided in the do...
# general
p
Hi there, Tweaking the example provided in the docs,
Copy code
rust

 let db = Db::open_with_opts(path.clone(), db_options, os.clone())
        .await
        .expect("failed to open db");

    let mut i = 0;
    println!("Inserting keys...");
    loop {
        db.put(format!("key_{}", i), b"test")
            .await
            .expect("failed to put");
        i += 1;

        println!("Inserted key_{}", i);
        if i >= 10000000 {
            break;
        }
    }

    db.close().await.expect("failed to close db");
I seem to get only one put per
flush_interval
, I feel that I may be missing something obvious?
c
Mind sharing your db_options, too?
p
Ahh, just caught
Copy code
println!("Writing 1000 keys without waiting for flush");
    let write_options = slatedb::config::WriteOptions {
        await_durable: false,
    };
Copy code
let mut db_options = DbOptions::default();
    db_options.flush_interval = Some(Duration::from_secs(60));
c
Yep!
Copy code
pub struct WriteOptions {
    /// Whether `put` calls should block until the write has been durably committed
    /// to the DB.
    pub await_durable: bool,
}

impl Default for WriteOptions {
    /// Create a new `WriteOptions`` with `await_durable` set to `true`.
    fn default() -> Self {
        Self {
            await_durable: true,
        }
    }
}
We defaulted for safety... writes don't ack (await blocks) until they're flushed to object storage.
You can relax this constraint with
await_durable
set to
false
p
Ah, that's great, indeed, that's faster
... 🙂
c
You can of course still control durability guarantees by calling
db.flush
manually
Otherwise, the flush interval will handle this for you.
p
I'm lurking this project for quite a bit, glad to finally got to try it out. I am currently using https://quickwit.io/ for the same purpose, but this is kind-of slow to query (around 3-4 secs per key)
c
Note that on close, a final flush is called, but if your process crashes, you might lose some data where put() was called, and await returned, but the data hasn't yet been flushed
p
Great, thank you
c
no prob! definitely nudge the channel if you need anything else
p
The goal is to provide storage for this endpointhttps://www.merklemap.com/certificates/ed60767615f9a1d0549e3bf6a1032681fbe87db26c6f9adcd48fddce142175c2 Around 18B docs to store for now, and I didn't want to do 18B puts to s3 for obvious reasons, ahaha
c
🤣 haha yep
Good use case
What size are the docs?
Ah, certs. Yep that should work really well 😄
p
Yes, around 5-8KB each
c
On the read side, you might want to look at on-disk caching to reduce S3 calls
p
I saw that
That's great!
c
😄
p
I keep running into needing something like slatedb in many projects I am part of, so I am kind of surprised that you guys are not all over the web already!
c
Haha, we'll get there. We did a splashy launch last year. Since then, it's been a lot of working and production rollout stuff. 😅