63 releases (36 stable)

new 4.3.5 Jul 16, 2024
4.3.2 Jun 11, 2024
4.2.6 Mar 4, 2024
4.2.5 Dec 23, 2023
1.0.0-alpha5 Nov 6, 2020

#155 in WebAssembly

Download history 8147/week @ 2024-03-25 9821/week @ 2024-04-01 12662/week @ 2024-04-08 9767/week @ 2024-04-15 8260/week @ 2024-04-22 4499/week @ 2024-04-29 7790/week @ 2024-05-06 7756/week @ 2024-05-13 6051/week @ 2024-05-20 8393/week @ 2024-05-27 5817/week @ 2024-06-03 14458/week @ 2024-06-10 14327/week @ 2024-06-17 6864/week @ 2024-06-24 20292/week @ 2024-07-01 25738/week @ 2024-07-08

71,987 downloads per month
Used in 19 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–16MB
~227K SLoC