58 releases (31 stable)

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

#625 in WebAssembly

Download history 9455/week @ 2024-01-23 10272/week @ 2024-01-30 8978/week @ 2024-02-06 6922/week @ 2024-02-13 6071/week @ 2024-02-20 6884/week @ 2024-02-27 6387/week @ 2024-03-05 9189/week @ 2024-03-12 5486/week @ 2024-03-19 9172/week @ 2024-03-26 9584/week @ 2024-04-02 13679/week @ 2024-04-09 8172/week @ 2024-04-16 7790/week @ 2024-04-23 3988/week @ 2024-04-30 7509/week @ 2024-05-07

30,820 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

~3–16MB
~216K SLoC