Skip to content

Tweak CachePolicy construction #15

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

CosmicHorrorDev
Copy link

@CosmicHorrorDev CosmicHorrorDev commented Apr 26, 2025

Changes the constructors to return Result<CachePolicy, NotStorable> where NotStorable is a wrapper that indicates the inner CachePolicy MUST NOT be stored, along with changing the base constructor to take an explicit time instead of internally calling SystemTime::now(). Both of these changes were handled through adding new constructors and deprecating the old ones

old

impl CachePolicy {
    pub fn new(&Req, &Res) -> Self { ... }
    pub fn new_options(&Req, &Res, SystemTime, CacheOptions) -> Self { ... }
}

new

impl CachePolicy {
    pub fn try_new(&Req, &Res, SystemTime) -> Result<Self, NotStorable> { ... }
    pub fn try_new_with_options(&Req, &Res, SystemTime, CacheOptions) -> Result<Self, NotStorable> { ... }
}

closes #13 closes #14

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.

Consider emphasizing storability Consider explicitly taking a SystemTime in CachePolicy::new()
1 participant