35 releases (15 stable)

new 3.2.0-beta.1 Mar 23, 2023
3.1.0 Dec 12, 2022
3.0.2 Nov 27, 2022
3.0.0-alpha.4 Jul 29, 2022
1.0.0-alpha5 Nov 6, 2020

#23 in WebAssembly

Download history 14827/week @ 2022-12-03 20242/week @ 2022-12-10 14672/week @ 2022-12-17 4056/week @ 2022-12-24 10146/week @ 2022-12-31 12731/week @ 2023-01-07 8945/week @ 2023-01-14 7884/week @ 2023-01-21 8084/week @ 2023-01-28 17497/week @ 2023-02-04 14684/week @ 2023-02-11 13738/week @ 2023-02-18 10121/week @ 2023-02-25 18090/week @ 2023-03-04 13747/week @ 2023-03-11 12518/week @ 2023-03-18

55,667 downloads per month
Used in 5 crates (4 directly)

MIT license

445KB
9K SLoC

wasmer-cache Build Status Join Wasmer Slack MIT License

The wasmer-cache crate allows to cache WebAssembly modules (of kind wasmer::Module) in your system, so that next uses of the module does imply a compilation time.

Usage

The Cache trait represents a generic cache for storing and loading compiled WebAssembly modules. The FileSystemCache type implements Cache to store cache on the file system.

use wasmer::{DeserializeError, Module, SerializeError};
use wasmer_cache::{Cache, FileSystemCache, Hash};

fn store_module(module: &Module, bytes: &[u8]) -> Result<(), SerializeError> {
    // Create a new file system cache.
    let mut fs_cache = FileSystemCache::new("some/directory/goes/here")?;

    // Compute a key for a given WebAssembly binary
    let hash = Hash::generate(bytes);

    // Store a module into the cache given a key
    fs_cache.store(hash, module.clone())?;

    Ok(())
}

Dependencies

~2.5–4.5MB
~101K SLoC