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

refactor: loose query key bound for in-memory cache #324

Merged
merged 1 commit into from
Apr 11, 2024
Merged

Conversation

MrCroxx
Copy link
Collaborator

@MrCroxx MrCroxx commented Apr 11, 2024

What's changed and what's your intention?

Please explain IN DETAIL what the changes are in this PR and why they are needed. :D

As title.

e.g.

pub fn get(&self, key: &K) -> Option<CacheEntry<K, V, L, S>>;

will be replaced with

unsafe fn get<Q>(&mut self, hash: u64, key: &Q) -> Option<NonNull<H>>
    where
        K: Borrow<Q>,
        Q: Hash + Eq + ?Sized;

to loose query key bound like:

let entry = cache.insert("hello".to_string(), "world".to_string(), 1);
let e = cache.get(&"hello".to_string()).unwrap();

can be rewritten with

let entry = cache.insert("hello".to_string(), "world".to_string(), 1);
let e = cache.get("hello").unwrap();

Checklist

  • I have written the necessary rustdoc comments
  • I have added the necessary unit tests and integration tests
  • I have passed make all (or make fast instead if the old tests are not modified) in my local environment.

Related issues or PRs (optional)

Signed-off-by: MrCroxx <mrcroxx@outlook.com>
@MrCroxx MrCroxx self-assigned this Apr 11, 2024
@MrCroxx MrCroxx enabled auto-merge (squash) April 11, 2024 17:27
@MrCroxx MrCroxx merged commit cc64fc9 into main Apr 11, 2024
10 checks passed
@MrCroxx MrCroxx deleted the xx/loose branch April 11, 2024 17:33
MrCroxx added a commit that referenced this pull request Apr 17, 2024
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant