A high-performance, concurrent, content-addressable disk cache, with support for both sync and async APIs. 💩💵 but for your 🦀
Go to file
Kat Marchán da259ae432
fix(perf): do the inner fn trick to reduce generic compilation load
2023-01-28 16:49:31 -08:00
.github fix(msrv): be less aggressive about MSRV bump 2023-01-28 15:55:00 -08:00
benches misc: clippy fixes 2023-01-28 15:55:01 -08:00
src fix(perf): do the inner fn trick to reduce generic compilation load 2023-01-28 16:49:31 -08:00
.gitignore meta: remove Cargo.lock from git 2019-12-16 18:54:59 -08:00
CHANGELOG.md docs: update changelog 2022-02-25 09:05:36 -08:00
CODE_OF_CONDUCT.md doc(readme): filled out README; added CoC and CONTRIBUTING.md 2019-07-01 00:04:52 -07:00
CONTRIBUTING.md doc(readme): filled out README; added CoC and CONTRIBUTING.md 2019-07-01 00:04:52 -07:00
Cargo.toml tests: stop spawning a new tokio runtime every benchmark iteration 2023-01-28 15:55:00 -08:00
LICENSE.md feat(license): change license to Apache-2.0 2021-09-15 19:52:50 -07:00
Makefile.toml meta: add publishing bits 2021-09-15 19:42:52 -07:00
README.md feature(async): Add tokio as an executor option (#36) 2023-01-28 13:01:59 -08:00
cliff.toml meta: add publishing bits 2021-09-15 19:42:52 -07:00
justfile feature(async): Add tokio as an executor option (#36) 2023-01-28 13:01:59 -08:00

README.md

cacache CI crates.io

A high-performance, concurrent, content-addressable disk cache, optimized for async APIs.

Example

use cacache;
use async_attributes;

#[async_attributes::main]
async fn main() -> Result<(), cacache::Error> {
    let dir = String::from("./my-cache");

    // Write some data!
    cacache::write(&dir, "key", b"my-async-data").await?;

    // Get the data back!
    let data = cacache::read(&dir, "key").await?;
    assert_eq!(data, b"my-async-data");

    // Clean up the data!
    cacache::rm::all(&dir).await?;
}

Install

Using cargo-edit

$ cargo add cacache

Minimum supported Rust version is 1.43.0.

Documentation

Features

  • First-class async support, using either async-std or tokio as its runtime. Sync APIs are available but secondary
  • std::fs-style API
  • Extraction by key or by content address (shasum, etc)
  • Subresource Integrity web standard support
  • Multi-hash support - safely host sha1, sha512, etc, in a single cache
  • Automatic content deduplication
  • Atomic content writes even for large data
  • Fault tolerance (immune to corruption, partial writes, process races, etc)
  • Consistency guarantees on read and write (full data verification)
  • Lockless, high-concurrency cache access
  • Really helpful, contextual error messages
  • Large file support
  • Pretty darn fast
  • Arbitrary metadata storage
  • Cross-platform: Windows and case-(in)sensitive filesystem support
  • Punches nazis

async-std is the default async runtime. To use tokio instead, turn off default features and enable the tokio-runtime feature, like this:

[dependencies]
cacache = { version = "*", default-features = false, features = ["tokio-runtime"] }

Contributing

The cacache team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The Contributor Guide has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.

All participants and maintainers in this project are expected to follow Code of Conduct, and just generally be excellent to each other.

Happy hacking!

License

This project is licensed under the Apache-2.0 License.