leveldb-rs icon indicating copy to clipboard operation
leveldb-rs copied to clipboard

How to ensure the LRU cache is thread safe?

Open uran0sH opened this issue 2 years ago • 3 comments

The LRU cache implemented in cache.rs is not thread safe. I'd like to know how you ensure that it is thread-safe

uran0sH avatar Feb 15 '23 15:02 uran0sH

Well as you say, it isn't thread-safe and not made to be. That's why it isn't Sync.

Do you mean to ask how it could be made thread-safe?

dermesser avatar Feb 16 '23 08:02 dermesser

Yeah. I thought you made sure the LRU cache was thread-safe elsewhere. I wrote a perhaps thread-safe LRU cache. Maybe you can give some advice? https://github.com/uran0sH/dsa-rs/blob/main/src/concurrent_lru.rs

uran0sH avatar Feb 20 '23 15:02 uran0sH

As my cache isn't concurrent, it is built quite differently from yours, so right away I can't give good advice I'm afraid.

dermesser avatar Feb 26 '23 07:02 dermesser