76 releases (44 stable)

new 6.0.0-beta.1 Mar 7, 2025
5.0.5-rc1 Jan 3, 2025
5.0.4 Dec 17, 2024
5.0.2 Nov 25, 2024
1.0.0-alpha5 Nov 6, 2020

#1261 in WebAssembly

Download history 9351/week @ 2024-11-21 9715/week @ 2024-11-28 7433/week @ 2024-12-05 8275/week @ 2024-12-12 3505/week @ 2024-12-19 14476/week @ 2024-12-26 13907/week @ 2025-01-02 18349/week @ 2025-01-09 19458/week @ 2025-01-16 22588/week @ 2025-01-23 15372/week @ 2025-01-30 15889/week @ 2025-02-06 15772/week @ 2025-02-13 26397/week @ 2025-02-20 25411/week @ 2025-02-27 28719/week @ 2025-03-06

97,868 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
~179K SLoC