58 releases (31 stable)

4.3.0 May 10, 2024
4.3.0-alpha.1 Apr 25, 2024
4.2.6 Mar 4, 2024
4.2.5 Dec 23, 2023
1.0.0-alpha5 Nov 6, 2020

#543 in WebAssembly

Download history 8777/week @ 2024-01-28 11212/week @ 2024-02-04 6648/week @ 2024-02-11 6007/week @ 2024-02-18 5038/week @ 2024-02-25 7028/week @ 2024-03-03 8356/week @ 2024-03-10 6972/week @ 2024-03-17 7335/week @ 2024-03-24 10560/week @ 2024-03-31 12614/week @ 2024-04-07 9878/week @ 2024-04-14 7710/week @ 2024-04-21 4752/week @ 2024-04-28 7856/week @ 2024-05-05 7737/week @ 2024-05-12

28,272 downloads per month
Used in 15 crates (5 directly)

MIT license

595KB
12K 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

~3–16MB
~219K SLoC