fcache 0.2.0

File caching library with lazy creation, automatic refresh, and callback-based initialization
Documentation

fcache

GitHub Build docs.rs MSRV unsafe forbidden LICENSE

A Rust library for efficient file caching with a straightforward interface for creating, retrieving, and managing cached files efficiently.

Setup

Add this to your Cargo.toml:

[dependencies]
fcache = "0.2.0"

Alternatively, you can use the cargo add subcommand:

cargo add fcache

Usage

Use the library functions to create cache instances and manage files:

use fcache::prelude::*;

fn main() -> fcache::Result<()> {
    // Create a new cache instance
    let cache = fcache::new()?;

    // Create a file with callback
    let cache_file = cache.get("data.txt", |mut file| {
        file.write_all(b"Hello, World!")?;
        Ok(())
    })?;

    // Read from the file
    let mut content = String::new();
    cache_file.open()?.read_to_string(&mut content)?;
    println!("Content: {}", content);

    Ok(())
}

For more usage examples, refer to the documentation available at docs.rs.

License

This crate is licensed under the MIT License.