al8n / stretto

Stretto is a Rust implementation for Dgraph's ristretto (https://github.com/dgraph-io/ristretto). A high performance memory-bound Rust cache.
Apache License 2.0
413 stars 28 forks source link

Removed unused Borrow trait requirements #53

Open peter-scholtens opened 1 year ago

peter-scholtens commented 1 year ago

As mentioned in https://github.com/al8n/stretto/issues/50 question 1, the unused Borrow trait requirements are removed. Some other code is aligned using rustfmt --edition 2021

codecov[bot] commented 1 year ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 85.40%. Comparing base (cccb12b) to head (d350418). Report is 2 commits behind head on main.

:exclamation: Current head d350418 differs from pull request most recent head 34e6023. Consider uploading reports for the commit 34e6023 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #53 +/- ## ========================================== - Coverage 85.74% 85.40% -0.34% ========================================== Files 17 17 Lines 1831 1830 -1 ========================================== - Hits 1570 1563 -7 - Misses 261 267 +6 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

al8n commented 1 year ago

Thanks! But I just found that if we remove the borrow limit, we are unable to limit the Q related to the type of the key.

Basically, I think we can add a new kind of Cache, which only requires a generic for Value, and in that kind cache, we remove the borrow limitation there and accept any kind of key.

peter-scholtens commented 1 year ago

Okay, I leave the choice to you. You mean adding a new cache like the example I proposed here? You can abbreviate it to BKeyCache or BKCache and let it coexist with the current implementation first. Once the new cache is mature enough you can set the other one as deprecated and even later on remove or alias it to the new implementation.