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

Taking Snapshots of the Cache to Disk #123

Closed
kutchar opened this issue Sep 21, 2016 · 5 comments
Closed

Taking Snapshots of the Cache to Disk #123

kutchar opened this issue Sep 21, 2016 · 5 comments

Comments

@kutchar
Copy link

kutchar commented Sep 21, 2016

What would be the best way to snapshot the cache state to disk (all the elements and their expirations) on some interval to be able to recover the cache when the process restarts?

@ben-manes
Copy link
Owner

Take a look at the Policy api. It provides snapshot iteration order and the ability to query the internal metadata.

@kutchar
Copy link
Author

kutchar commented Sep 21, 2016

I'm assuming you're referring to the following, right?

Policy.Expiration.oldest
Policy.Expiration.youngest
Policy.Expiration.getExpiresAfter

So considering the oldest and youngest are not constant time, wouldn't it be better to use the asMap since I just need a snapshot of the cache and not necessarily in any order?

Also, I'm assuming in either case I have to iterate through the iterator and call Expiration.getExpiresAfter on each item to get the expiration, correct?

@ben-manes
Copy link
Owner

If you don't care about order then, as you said, using asMap and ageOf would be best.

@kutchar
Copy link
Author

kutchar commented Sep 21, 2016

Thanks :)

@ben-manes
Copy link
Owner

If you run into any snags be sure to let me know.

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

No branches or pull requests

2 participants