56 releases (30 stable)

new 4.3.0-alpha.1 Apr 25, 2024
4.2.6 Mar 4, 2024
4.2.5 Dec 23, 2023
4.2.3 Oct 27, 2023
1.0.0-alpha5 Nov 6, 2020

#342 in WebAssembly

Download history 6084/week @ 2024-01-05 10651/week @ 2024-01-12 15888/week @ 2024-01-19 6632/week @ 2024-01-26 13989/week @ 2024-02-02 6777/week @ 2024-02-09 5343/week @ 2024-02-16 4791/week @ 2024-02-23 7176/week @ 2024-03-01 8603/week @ 2024-03-08 7156/week @ 2024-03-15 7051/week @ 2024-03-22 10515/week @ 2024-03-29 9828/week @ 2024-04-05 12632/week @ 2024-04-12 6545/week @ 2024-04-19

41,032 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

~4–13MB
~167K SLoC