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

Make all caches' store public #94

Merged
merged 1 commit into from
Oct 21, 2021
Merged

Make all caches' store public #94

merged 1 commit into from
Oct 21, 2021

Conversation

naucke
Copy link
Contributor

@naucke naucke commented Oct 19, 2021

(was pub(super)). This makes it possible to manually dump a cache, so
its contents can be saved and restored later.

Related to (but does not directly fix) #20.

@@ -18,7 +18,7 @@ use {super::CachedAsync, async_trait::async_trait, futures::Future};
#[derive(Clone)]
pub struct SizedCache<K, V> {
// `store` contains a hash of K -> index of (K, V) tuple in `order`
pub(super) store: RawTable<usize>,
pub store: RawTable<usize>,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we should really make this one public since modifying it without updating the lru-list would cause some problems. Could we add a method to get a &RawTable<usize> instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Yes, an immutable reference is probably better.
  • I hadn't read SizedCache's API very carefully; doesn't it make more sense to provide access to order?
  • I think it's more consistent to use a function for all.

see updated commit, tell me what you think

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

For all caches, add a function to get an immutable reference to their
contents. This makes it possible to manually dump a cache, so its
contents can be saved and restored later.
@jaemk
Copy link
Owner

jaemk commented Oct 21, 2021

thanks!

@jaemk jaemk merged commit 753e0df into jaemk:master Oct 21, 2021
@jaemk
Copy link
Owner

jaemk commented Oct 21, 2021

released in 0.26.0

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

Successfully merging this pull request may close these issues.

2 participants