78 releases (46 stable)

6.0.0 Apr 24, 2025
6.0.0-beta.1 Mar 7, 2025
6.0.0-alpha.2 Feb 26, 2025
5.0.6 May 2, 2025
1.0.0-alpha5 Nov 6, 2020

#1248 in WebAssembly

Download history 18914/week @ 2025-01-10 19823/week @ 2025-01-17 21174/week @ 2025-01-24 19024/week @ 2025-01-31 13183/week @ 2025-02-07 19046/week @ 2025-02-14 28618/week @ 2025-02-21 28121/week @ 2025-02-28 20610/week @ 2025-03-07 45129/week @ 2025-03-14 28898/week @ 2025-03-21 28997/week @ 2025-03-28 28462/week @ 2025-04-04 17739/week @ 2025-04-11 14979/week @ 2025-04-18 14670/week @ 2025-04-25

78,379 downloads per month
Used in 23 crates (6 directly)

MIT license

1MB
26K 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–14MB
~183K SLoC