Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use generic key-val store #87

Open
gauteh opened this issue Jul 2, 2020 · 2 comments
Open

Use generic key-val store #87

gauteh opened this issue Jul 2, 2020 · 2 comments

Comments

@gauteh
Copy link

gauteh commented Jul 2, 2020

Hi,

I am using this crate now and I think it performs really well. However, I am using it in a concurrent server, and I currently have to wrap in Arc<RwLock<..>>. It would be great if it was possible to plug in dashmap to make the LRU thread-safe. The best would be if it would be generic over key-value store, then even remote stores could be used. This would probably involve implementing a K-V trait for a few selected collections, or newtype for users who wish to use un-implemented external structures. What do you think?

Related to #21

@jeromefroe
Copy link
Owner

Hi @gauteh! I like this idea, but I think it may be tricky to implement because the cache uses both a hashmap and a linked list internally. So while it may be fairly straightforward to swap out the current hashmap with dashmap, converting the linked list to support concurrent operations will likely be more difficult because it's implemented by hand. And then, even if both the hashmap and linked list supported concurrent operations, we would still have to ensure that their composition also supported concurrent operations correctly as well. With that being said, I'm certainly not opposed to the idea, it's just that I think it would take a good chunk of work and I'm not sure I'd be able to devote the necessary amount of time to it. I'd love to be proven wrong though if you have different thoughts on how to approach this?

@matklad
Copy link
Contributor

matklad commented Sep 6, 2022

For the reference, at near we are using Arc<Mutex> as well, wrapped into this data structure:

https://github.com/near/nearcore/blob/master/utils/near-cache/src/sync.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants