53 releases (28 stable)

4.2.5 Dec 23, 2023
4.2.3 Oct 27, 2023
4.1.0 Jul 24, 2023
3.3.0 May 3, 2023
1.0.0-alpha5 Nov 6, 2020

#17 in WebAssembly

Download history 15471/week @ 2023-11-06 15242/week @ 2023-11-13 13664/week @ 2023-11-20 10538/week @ 2023-11-27 14390/week @ 2023-12-04 8930/week @ 2023-12-11 9470/week @ 2023-12-18 3139/week @ 2023-12-25 12910/week @ 2024-01-01 8678/week @ 2024-01-08 15259/week @ 2024-01-15 9856/week @ 2024-01-22 8706/week @ 2024-01-29 11229/week @ 2024-02-05 6845/week @ 2024-02-12 6856/week @ 2024-02-19

34,336 downloads per month
Used in 15 crates (5 directly)

MIT license

605KB
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

~4–11MB
~120K SLoC