sled icon indicating copy to clipboard operation
sled copied to clipboard

Functionality to check if a key is present in cache

Open Frederik-Baetens opened this issue 4 years ago • 1 comments

I understand from #1123 that sled can be much more performant by not using async, and it's users likely could be too. However, a lot of users are forced into using async by the libraries (e.g. RPC with tonic) they're using. For those using async, and a database too large to fit into memory, it would be convenient if there were a method to check if a key is present in the cache, so they can avoid calling spawn_blocking in that case.

Or are there better patterns async users can use when their dataset doesn't fit into memory? Would just using spawn_blocking all the time incur negligible performance costs?

Use Case:

Avoiding some of the spawn_blocking calls currently needed when using sled with async

Proposed Change:

Method to check if a key is present in the cache

Who Benefits From The Change(s)?

Async users

Alternative Approaches

Async wrappers around sled's operations, so no operation is blocking in the first place

Frederik-Baetens avatar Feb 10 '22 01:02 Frederik-Baetens

I second this. At first glance, maybe it could also unlock use cases for sled-based persistence layers to make their decision about whether to load referenced K/Vs eagerly or lazily depending on whether they are cached already anyway ("get them while they're hot" 😄 ).

Gearme avatar Feb 25 '22 11:02 Gearme