69 releases (41 stable)

new 5.0.1 Nov 6, 2024
4.4.0 Oct 4, 2024
4.3.5 Jul 16, 2024
4.2.6 Mar 4, 2024
1.0.0-alpha5 Nov 6, 2020

#727 in WebAssembly

Download history 22754/week @ 2024-07-18 12210/week @ 2024-07-25 21469/week @ 2024-08-01 20077/week @ 2024-08-08 30763/week @ 2024-08-15 22108/week @ 2024-08-22 12435/week @ 2024-08-29 12198/week @ 2024-09-05 5587/week @ 2024-09-12 10250/week @ 2024-09-19 8487/week @ 2024-09-26 10832/week @ 2024-10-03 12533/week @ 2024-10-10 10315/week @ 2024-10-17 12330/week @ 2024-10-24 12225/week @ 2024-10-31

47,858 downloads per month
Used in 22 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
~196K SLoC