Skip to content

Cache not refreshed. #99

@lz1998

Description

@lz1998

I use cached to check whether a key exist in the past 2 seconds, and I write an unit test, but it doesn't works.

#[cfg(test)]
mod tests {
    use std::thread::sleep;

    use cached::Cached;

    #[test]
    fn a() {
        let mut c = cached::TimedCache::with_lifespan_and_refresh(2, true);
        for i in 1..5 {
            let key = i.to_string().repeat(9999999);
            let value = true;
            c.cache_set(key, value);
            sleep(std::time::Duration::from_secs(1));
            // println!("{:?}", c.get_store());
        }
        assert!(c.cache_set(1.to_string().repeat(9999999), true).is_none());
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions