ex0dus-0x / microkv

Minimal and persistent key-value store designed with security in mind
MIT License
32 stars 6 forks source link

Usefulness of locks #14

Closed plainerman closed 1 year ago

plainerman commented 1 year ago

Thank you for creating this awesome project. The only issue I have is that the current state of the read and write lock are lacking helper functions to be useful. I see the following main issues:

1) microkv uses bincode serialization, when only having the IndexMap (e.g., read or write lock) users would have to do the serialization + encryption themselves 2) making matters worse, external encryption part cannot rely on the stored secret as it is private. So users would need to store it in a second place 3) formatting the namespace strings is private, so users cannot access them and need to build them in the closure themselves (which is not very nice)

I propose we extend the index map in such a way that we have helper functions (that are also used internally by the namespaces). With them, users can use them inside a lock like this

db.lock_write(|mut kv| {
    kv.kv_put(db, "namespace", "key", 1);
}

I created a PR that serves as a proposal to discuss a a possible direction we could go to solve this problem (#15). If this is the way we want to go, I can extend it to the remaining useful functions and we can merge the PR.

I would love to hear your opinion on this issue.