73 releases (44 stable)

new 5.0.5-rc1 Jan 3, 2025
5.0.4 Dec 17, 2024
5.0.2 Nov 25, 2024
4.4.0 Oct 4, 2024
1.0.0-alpha5 Nov 6, 2020

#1211 in WebAssembly

Download history 8764/week @ 2024-09-20 8330/week @ 2024-09-27 13661/week @ 2024-10-04 12043/week @ 2024-10-11 10032/week @ 2024-10-18 11418/week @ 2024-10-25 11574/week @ 2024-11-01 9505/week @ 2024-11-08 7191/week @ 2024-11-15 8275/week @ 2024-11-22 9381/week @ 2024-11-29 8145/week @ 2024-12-06 7872/week @ 2024-12-13 5146/week @ 2024-12-20 12985/week @ 2024-12-27 12902/week @ 2025-01-03

40,034 downloads per month
Used in 18 crates (5 directly)

MIT license

740KB
15K 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–14MB
~191K SLoC